qsv
qsv copied to clipboard
cat rowskey: Read list of files from stdin
Is your feature request related to a problem? Please describe.
Right now, to cat
several files, qsv
allows:
qsv cat rowskey --group fullpath --group-name path 1.tsv 2.tsv
or
find . -name '*.tsv' > /tmp/input.infile-list
qsv cat rowskey --group fullpath --group-name path /tmp/input.infile-list
But I think the easiest way would be to:
find . -name '*.tsv' | qsv cat rowskey --group fullpath --group-name path
This is currently not supported, as qsv
treats stdin
as another file.
Describe the solution you'd like
Not sure what the best solution would be, but I'd say to add another option (e.g. --in-list
) that would specify if the input is a file or a list of files. This would allow:
qsv cat rowskey --group fullpath --group-name path 1.tsv 2.tsv
and (independent of file name):
find . -name '*.tsv' > /tmp/input.list
qsv cat rowskey --group fullpath --group-name path --in-list /tmp/input.list
and:
find . -name '*.tsv' | qsv cat rowskey --group fullpath --group-name path --in-list
One disadvantage is that it would not allow for mixed inputs (i.e. both files and lists of files) as arguments:
qsv cat rowskey --group fullpath --group-name path 1.tsv 2.tsv /tmp/input.list
but this could be achieved with:
ls 1.tsv 2.tsv | qsv cat rowskey --group fullpath --group-name path --in-list /tmp/input.list
Thanks @fgvieira for the detailed request.
However, qsv's Extended Input Support is used by other commands apart from cat
- headers
, sqlp
and to
, so I'll need to consider how your request affects those commands as well.
Just the same, I'll add your request to the backlog.
I believe the solution is easy by the use of xargs. It becomes
find . -name '*.tsv' | xargs qsv cat rowskey --group fullpath --group-name path
@13minutes-yt 's solution is cleaner and more elegant.
Moving this to Discussions so other folks can discover it if they have a similar problem.