Why CSV?
CSV is a terrible formst for data. TSV is superior in every way, and XML is far more robust (but horribly verbose). Somehow, CSV remains popular. Software engineers seem completely resigned to it, often supporting CSV and not even allowing TSV, let alone subtly suggesting it by, say, defaulting to it in export options.
What's wrong with CSV?
the basic problem with CSV is that it uses fairly common characters (comma and the inch symbol commonly used as a quotation mark) to separate data fields that may include both commas and quotation marks.
This means that, despite its apparent simplicitly, CSV requires a stateful parser to ingest and in fact cannot be handled perfectly.
There is in fact no standatd for CSV.
A quick search for the "best csv parser for javascript"
yields lots of articles listing alternatives. fast-csv
has a bundle-size of 57kB (16kB gzipped).
It's ridiculous.
What's great about TSV
TSV uses the ASCII control charactets (tab and newline) that were literally designed for the express purpose of delimiting tabular data. If you need to include tab and newline characters within the data, there's a simple standard way to do it.
Not only are there dedicated keys on every keyboard for dealing with TSV, many text editors and word-processors will do a pretty good job of displaying the content of TSVs nicely, and the files will tend to be slightly smaller.
Parsing TSVs is so simple that it doesn't really deserve the word "parsing". You don't need a library, in TypeScript / Javascript it's basically one line of code…
function parseTsv(source: string): string {
return source.split('\n').map(line => line.split('\t'))
}
Please, please stop using CSV.
Post Script
At a meeting yesterday I discussed this issue with several of my non-technical (Finnish) colleagues and they did not know TSV is even an option but pointed out that they have huge issues with European decimal points (i.e. commas) in spreadsheet output. So it's even worse in Europe.