Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsv edit - Edit a specific cell with a new value by row and column #2046

Closed
rzmk opened this issue Aug 12, 2024 · 5 comments
Closed

qsv edit - Edit a specific cell with a new value by row and column #2046

rzmk opened this issue Aug 12, 2024 · 5 comments

Comments

@rzmk
Copy link
Collaborator

rzmk commented Aug 12, 2024

Is your feature request related to a problem? Please describe.
Looking for a relatively simple interface to edit a specific cell within a spreadsheet. Editing a specific cell with a new value, maybe called qsv edit.

Describe the solution you'd like
qsv command that lets a user specify a row and cell to edit with a new value. At a basic level the cell can be replaced with a string and in the future could consider regex, etc.

For example if I want to replace the cell value comb with notebook as shown in the following image then I'd run a command using the row and column indices:

Untitled

qsv edit items.csv 2 2 "notebook"

Or something similar (-x/col and -y/row flags? different input order? index change based on header value or choose 0 vs 1 index? choose column by column name? choose row by a specific column's value? validate cell editing by an optional schema input?)

Describe alternatives you've considered
qsv replace but that interface may be too much for this specific use case where a user may just want to edit a single cell with a new value (and no regex by default).

@rzmk
Copy link
Collaborator Author

rzmk commented Aug 12, 2024

Another idea in future implementations could be subcommands qsv edit cells, qsv edit rows, and qsv edit columns to edit one or multiple cells/row/columns somehow. For the initial implementation though this issue is regarding editing a single cell.

@jqnatividad
Copy link
Collaborator

Great idea!

For consistency, I would use select syntax for setting the column/s. For selecting the rows, I would use slice syntax.

I agree that for the initial implementation, let's just keep it to a single cell. And then when you want to operate on multiple columns/rows, to have the columns and rows subcommands respectively.

@rzmk
Copy link
Collaborator Author

rzmk commented Aug 13, 2024

Can you show an example of the what this command would look like using that syntax?

@jqnatividad
Copy link
Collaborator

jqnatividad commented Aug 13, 2024

I think the main thing is to maintain consistency within the qsv suite.

That is, for column/row selection - qsv does it with select/slice.

So edit should use their syntax, but only operating on single cells for the initial implementation.

Specifically, for column selection, support names. For row selection, that it be 0-based like slice.

# for your example above
qsv edit items.csv item 1 "notebook"

# edit the last column, 3rd row
qsv edit items.csv _ 2 "1.99"

In that way, by being consistent with select/slice syntax/semantics for single cell editing, you can implement multi-column/multi-row editing in a qsv-consistent way when you do choose to implement compound editing in the future.

WDYT?

rzmk added a commit that referenced this issue Aug 22, 2024
@jqnatividad
Copy link
Collaborator

Closing this with the edit command merged. Thanks @rzmk !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants