BurntSushi / xsv

A fast CSV command line toolkit written in Rust.
The Unlicense
10.29k stars 317 forks source link

Auto-detect delimiter #294

Open harrybiddle opened 2 years ago

harrybiddle commented 2 years ago

Unfortunately, I am not in an environment where .csv files are always comma-separated and .tsv files are tab-separated. In my work I unfortunately frequently encounter semi-colon separated files.

It would be incredibly useful if xsv detected the delimiter for me. I tried to achieve this using a bash wrapper, but it was a bit fiddly because I need to do different things depending on whether xsv is being passed a file (in which case I sniff the file and then pass the delimiter to the xsv command) or a stream (in which case I sniff the stream, and then pass the amount I've already sniffed plus the rest of the stream to xsv).

My little hacky wrapper works (mostly!) but it would be much better implemented in xsv itself.

Possibly there could be an environment variable to set "auto-detect delimiter" as the default mode a-la #44.