Sample Header Ad - 728x90

How to get well-formed table from comm?

1 vote
2 answers
37 views
I want to use the output of comm in other table parsers. However it seems like it produces inconsistently delimited rows. For example:
$ comm <(echo "1\n2") <(echo "2\n3") | bat -A --style=plain
1␊
├──┤├──┤2␊
├──┤3␊
Because it's not padding with remaining tabs, I can't convert it to a CSV:
$ comm <(echo "1\n2") <(echo "2\n3") | tr \\t ,
1
,,2
,3
And can't ingest it as tab-delimited either:
$ comm <(echo "1\n2") <(echo "2\n3") | xsv input -d \\t
1
CSV error: record 1 (line: 2, byte: 2): found record with 3 fields, but the previous record has 1 fields
Is there a way to make comm produce a properly formatted table? The options I can see seem like more work than they should be: * Replace with a regex * Print each column separately
Asked by Haterind (189 rep)
Sep 20, 2021, 06:52 PM
Last activity: Sep 20, 2021, 08:09 PM