Files containing data arrange in a table, often with commas (hence Comma Separated Values), to separate columns. Rows are separated by newlines (but not all newlines are row separators as fields can be quoted to contain the separator newlines. Use this tag for full-fledged CSV data not the simpler case of one record per line or completely unquoted (use csv-simple for that kind of data).
Files in CSV (comma-separted values) format contain tabular data, with rows separated by newlines and columns—normally—separated by a comma (,
). Not every newline has to be a row separator.
There are many CSV variants (partly caused by language settings of the generating spreadsheet programs), so the separator might differ (semi-colon is common in CSVs generated by German software, tabs in others) and cell content might not be quoted ("..."
)if not necessary (if not containing the separator character nor any newlines).
Tools like awk
and grep
are only suitable for simplified CSV files without quotes and cells with newlines. Use csv-simple for those files not csv.
For normal CSV files (quotes around fields, newlines and separator character in fields), use a proper CSV parser and tell it what quoting rules the file uses—see Is there a robust command line tool for processing csv files?