-
Notifications
You must be signed in to change notification settings - Fork 45
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
feature request: match columns by name #47
Comments
Hi @bergey, this is an interesting idea. Should be pretty easy to implement by updating the code that runs at the beginning of the program to create the I think to flesh out the design/use case and hone in on what would be good re: exact-match, prefix, case sensitivity, it would be great to look at some example use cases. Do you have any on hand already? It would also be great to look at existing tools that produce similar header row lines, although existing tools will probably be stable enough that exact-match would be good enough for those use cases. excited to hear more thoughts on this! |
Here is output from some commands with which I envision using this feature. (Header & first line of data only).
I'm thinking exact-match is the right place to start. The other options I mentioned would save a little typing in some circumstances, but I'm not sure if they'd be worth the added learning curve. I imagine we can add more flexible matching later if we wish for it once we have the exact-match version. So something like:
Or should we hide this new behavior behind a flag?
What do you think about mixing numeric & text selectors?
I worry that it's ambiguous if some header has an all-digit header, but maybe that's rare enough in practice? Or maybe the |
this is a great start and good examples, thanks for finding them. to directly address some of the open ended parts of your question:
strong agree!
this unfortunately could lead to a pretty bad user experience. in the situation where a two word header is at the beginning of the line, if we don't handle that somehow the entire line's headers will be useless, and even worse that will be pretty unintuitive to the user.
I think that would be wise, and would allow support for numerical header fields without breaking backwards compatibility.
I think that would be good. In order to mix and match while headers are behind a flag, I think each header string would need to be prefaced by the flag, i.e. that flag can be repeated many times. Otherwise you would have an issue where there is ambiguity between numbers and numerical headers, OR you would have to have all numerical choices come before all header choices (if you had one |
Thanks @darked89 for pointing that out. If xsv already implements that then I think it's best to leave it out of choose. Let's do one thing and do it well, and not reimplement other tools. |
I'd like
choose
to take an option under which it treats the first row as headers, and allows selecting columns by name. This saves counting, and is especially nice in scripts where it's more clear what is going on and somewhat more resilient to changes in the input format. Not sure if it should be exact-match, prefix, case-insensitive....I'm happy to open a PR if you like this idea.
The text was updated successfully, but these errors were encountered: