qsv icon indicating copy to clipboard operation
qsv copied to clipboard

cat rowskey: Read list of files from stdin

Open fgvieira opened this issue 1 year ago • 1 comments

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

fgvieira avatar Feb 08 '24 14:02 fgvieira

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.

jqnatividad avatar Feb 09 '24 13:02 jqnatividad

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 avatar Mar 07 '24 17:03 13minutes-yt

@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.

jqnatividad avatar Mar 08 '24 10:03 jqnatividad