miller icon indicating copy to clipboard operation
miller copied to clipboard

Zero-length CSV files

Open spmundi opened this issue 5 years ago • 4 comments

Can mlr be changed so that it does not correct zero length .csv files?

It is quite awkward to handle those files in other programs, and in mlr itself I believe. For instance you join two files with, as it happens, no matching keys. You expect to create a third file and perform another mlr operation eg sort, or cut.. whatever. But you get a zero length file, which does not therefore have any column names. Put another way: what should a .csv without any data be? I contend it should be a single line with field names, not a zero length file.

spmundi avatar Feb 29 '20 05:02 spmundi

that word in the first sentence should be "create" not "correct".I cannot figure out how to edit my comment once posted.

spmundi avatar Feb 29 '20 05:02 spmundi

I recognize that this has no applicability to other formats (well, some other formats anyway. Have not thought it through in detail)

spmundi avatar Mar 09 '20 15:03 spmundi

@spmundi re editing comments -- there is a ... at the upper-right-hand corner of each comment box. Click on that & you'll see 'edit'.

Yes, the header-only CSV file ............................ I really don't know how to handle this in Miller. :(

johnkerl avatar Mar 09 '20 19:03 johnkerl

Same when filtering:

mlr --tsv filter '$n >= 100' input.tsv

If there are no rows, output file is empty (no header). I would also argue that an empty CSV/TSV file should keep the header.

fgvieira avatar Feb 15 '24 11:02 fgvieira