Specifing output formats on stdout #2682
-
I have a bunch of shell scripts that operate on tsv files using But I had some challenges when trying to use it in pipes. This is challenging because The Another surprise was that Or loading a tsv file should result in tsv output. If there are multiple input files in different formats I'm not sure the best behavior but it seems like I would expect to have to specify Describe the solutions you'd like
Proposed priority for selecting output format (first wins):
Describe alternatives you've considered I can do these sorts of things everywhere:
Personal opinion: having to do that feels disappointing and unsatisfying. |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 5 replies
-
@jstorrs , have you tried setting https://github.com/dathere/qsv/blob/master/docs/ENVIRONMENT_VARIABLES.md If that works, you can make it the default setting in your qsv installation by setting the dotenv file. https://github.com/dathere/qsv/blob/master/docs/ENVIRONMENT_VARIABLES.md#env-file-support As with most things open-source, the defaults of qsv follow the reqts/scratches we're itching. We get data in all shapes, sizes and quality - and qsv's output defaults to the CSV dialect we use in our pipelines. I'm actually weighing changing the default delimiter to |
Beta Was this translation helpful? Give feedback.
-
Thank you! Setting that environment variable seems to work for me and it's easy enough to add it to a script. I don't really like the global envrc ideas because it makes the command behavior depend on system configuration but that's admittedly nothing more than a preference. It seems likely to lead to more complexity when trying to debug problems. For me it's easy enough to rely on |
Beta Was this translation helpful? Give feedback.
-
But, you can easily write the env file in the working directory from your script at runtime and remove it afterwards. |
Beta Was this translation helpful? Give feedback.
-
I know you can do that. To me .env files are about storing paths and parameters or secrets. And it's probably fine for a script that's being built ad-hoc for use in a single project. But when you get to the point of having to generalize that script for use in multiple projects, then relying on having to setup .env files and audit them is just going to be a headache. The suggestions I made in the initial comment are just to document things that I find strange about the cli interface. I'm perfectly fine throwing environment variables into scripts. The whole .env file thing is just one way to manage environment variables. The reason I provided suggestions in the original comment is because the goals in README include
and I find it to be lacking in that regard. But that's just my opinion and I'm just providing feedback. |
Beta Was this translation helpful? Give feedback.
-
I like the env file written by my scripts (and not removed) so I can manually test steps in the script, without having to remember to set environment variables. But then there are different ways of achieving same goal. |
Beta Was this translation helpful? Give feedback.
-
I not interested in being lectured to about using |
Beta Was this translation helpful? Give feedback.
-
Wow!! |
Beta Was this translation helpful? Give feedback.
-
Advocating for one ugly hack vs another for working around limitations of the qsv cli doesn't make the failings of the qsv cli disappear. And frankly, I find it odd that qsv even reads .env files directly. There seems to be some confusion about the purpose of .env files vs configuration files and it's beyond the scope of the issue I opened. For configuration files it would be better for qsv to use XDG_CONFIG_HOME and XDG_CONFIG_DIRS etc (from the XDG Base Directory Specification). |
Beta Was this translation helpful? Give feedback.
-
Thanks @jstorrs for the feedback. I'm glad to know the QSV_DEFAULT_DELIMITER env var is working out of you. The choice of .env files for persisting configuration was really not deeply considered when I introduced it. We were using .env files for another project where we embed qsv and it was convenient for me to use it at the time. Will revisit using XDG configuration files in the future. Converting this issue to a discussion so other folks with a similar issue can easily find it. |
Beta Was this translation helpful? Give feedback.
-
I don't mind that .env file functionality exists, but it would be better if searching of .env files were optional and needed to be explicitly enabled when desired. At the very least there should be some way to turn .env file use off completely if we want to ensure behavior. Looking at utils.rs it looks like an option is |
Beta Was this translation helpful? Give feedback.
@jstorrs , have you tried setting
QSV_DEFAULT_DELIMITER
?https://github.com/dathere/qsv/blob/master/docs/ENVIRONMENT_VARIABLES.md
If that works, you can make it the default setting in your qsv installation by setting the dotenv file.
https://github.com/dathere/qsv/blob/master/docs/ENVIRONMENT_VARIABLES.md#env-file-support
As with most things open-source, the defaults of qsv follow the reqts/scratches we're itching. We get data in all shapes, sizes and quality - and qsv's output defaults to the CSV dialect we use in our pipelines.
I'm actually weighing changing the default delimiter to
\t
(tab) for our pipelines, so do let me know ifQSV_DEFAULT_DELIMITER
does the trick for you.