-
Notifications
You must be signed in to change notification settings - Fork 14
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
new option IMPF
: importable fields
#8
Conversation
…e table(s), default `nr,nf,0-`), can be used to exact specifying which fields should be imported from input (increases import performance, minimizes overhead and simplifies output of statements like `select * from a`, if e. g. fields like `anr`, `anf` and `a0` are not necessary or too many input fields available).
I like the idea of having this functionality and your code looks fine but I am not sure the design of the feature is right. Some thoughts:
I'm very interested in ideas to do with the second point. |
I'm closing this pull request because the functionality it adds (other than disabling |
Well, although looks not bad, but ... Partially I don't like it, e. g.: echo -e "A B C D\nA B C\nA B" | sqawk -FS " " -output json "select * from a" NF=1 MNF=crop skip=3-10 F0=0
[{"anr":"1","anf":"3","a1":"A","a2":"B"},{"anr":"2","anf":"3","a1":"A","a2":"B"},{"anr":"3","anf":"3","a1":"A","a2":"B"}] Cons that I see:
On the whole, I find my solution better (and I will continue to use it)... |
Thanks for the feedback! To me, the points about the negative handling and the wordiness seem especially strong. My primary reason for rejecting Ultimately, the problem might lie in trying to cram into a few command line options the kind thing that requires nothing less than a scripting language than to handle fully and well (a-la Greenspun's tenth rule). As for shaping JSON output, I do not consider that Sqawk's job. What I found was that, in practice, you'd sooner or later need a specialized tool like jq for it. (I highly recommend jq; it was an inspiration for Sqawk in the first place.) In your example you could use jq like this: echo -e 'A B C D\nA B C\nA B' \
| sqawk -FS ' ' -output json 'select * from a' NF=1 MNF=crop skip=3-10 F0=0 \
| jq 'map(del(.anr) | del(.anf))' For a more advanced example (converting JSON to Tcl dictionaries with jq) check out jqlang/jq#1228. Another thing to note is that it's unfortunate that you have to maintain a fork of Sqawk if you want to use functionality that isn't accepted into the core. Sqawk may need a plugin interface. Once again, I appreciate your feedback. I've created an issue (#9) for revising these options. |
new option
IMPF
introduced: describes fields to be imported into the table(s), defaultnr,nf,0-
), can be used to exact specifying which fields should be imported from input (increases import performance, minimizes overhead and simplifies output of statements likeselect * from a
, if e. g. fields likeanr
,anf
anda0
are not necessary or too many input fields available).Examples: