Open Kinrany opened 5 months ago
xsv table
doesn't print the parsed contents of CSV data. It just rewrites the input CSV as tab-delimited CSV, and then expands the tabs in the output as per elastic tabstops. This is easy to see in the implementation: https://github.com/BurntSushi/xsv/blob/4278b8593260bb2e9bfdf6e91cc4df5b7df5b8fb/src/cmd/table.rs#L49-L71
It does seem plausible that it would be better to print the parsed contents (i.e., after unescaping quotes).
The thing that confused me the most was that it does remove the quotes around "a"
.
Is the output of xsv table
intended to be parseable as CSV too?
The thing that confused me the most was that it does remove the quotes around
"a"
.
Yes, because the CSV writer knows when quotes are necessary. They aren't necessary to write a
.
Is the output of xsv table intended to be parseable as CSV too?
No. As I said, the tabs are expanded to spaces. So it's very deliberately not CSV. It's for human consumption. Which is arguably why this should be treated as a bug and the quotes should be unescaped.
That's what I thought!
Can I help? Xsv is a great tool 😄
xsv table
doesn't print the parsed contents of CSV data. It just rewrites the input CSV as tab-delimited CSV, and then expands the tabs in the output as per elastic tabstops. This is easy to see in the implementation:It does seem plausible that it would be better to print the parsed contents (i.e., after unescaping quotes).
I ran into something similar for xsv fmt --ascii
. Printing the parsed contents would be much more useful of a feature; one turns to ASV precisely so that you don't need to escape strings!
xsv fmt --table
? 🤔
xsv table
doesn't print the parsed contents of CSV data. It just rewrites the input CSV as tab-delimited CSV, and then expands the tabs in the output as per elastic tabstops. This is easy to see in the implementation: https://github.com/BurntSushi/xsv/blob/4278b8593260bb2e9bfdf6e91cc4df5b7df5b8fb/src/cmd/table.rs#L49-L71It does seem plausible that it would be better to print the parsed contents (i.e., after unescaping quotes).
I ran into something similar for
xsv fmt --ascii
. Printing the parsed contents would be much more useful of a feature; one turns to ASV precisely so that you don't need to escape strings!
xsv fmt --ascii
should definitely not print the parsed contents. It should print CSV data. And insert quoting when necessary. But it does look like it is inserting quotes when it shouldn't for --ascii
.
Example file:
Expected output:
Real output: