mithrandie / csvq

SQL-like query language for csv
https://mithrandie.github.io/csvq
MIT License
1.49k stars 65 forks source link

feature : set the default format to csv when the output is piped #71

Closed kpym closed 2 years ago

kpym commented 2 years ago

The text output format is not very useful when we use it as input to another program. Perhaps you can change the default format to csv if stdout is sent to another program. This can be done like in this SX answer but with os.Stdout instead of os.Stdin, I think.

ondohotola commented 2 years ago

In the meantime you can use '--format CSV'

el

kpym commented 2 years ago

@ondohotola I know that I can do this. Thanks.

mithrandie commented 2 years ago

It is possible to automatically change the format when piping output to a destination, but it is impossible to know how the data will be used at that destination. It also confuses users if the data differs from the output to the console. I think it should be specified explicitly by users.

ktzanev commented 2 years ago

Thanks for considering this request. I don't agree with your logic. The terminal output is supposed to be human readable. The pipe output is supposed to be machine readable. For example all good tools that have colorful terminal output produce raw (without colors) output when they are piped. I agree that the data should be the same, but the form should be adapted to humans or to machines. In any case it is your choice and I appreciate that you took the time to consider my request. 🙏

mithrandie commented 2 years ago

That makes sense. You may be right. I will add this fix to the next release. Thank you for explaining.

mithrandie commented 2 years ago

This feature has been included in version 1.17.3.

kpym commented 2 years ago

Fantastic ! Thank you for the quality of your work and your responsiveness 🙏