What is CSV? — Comma-Separated Values Explained
Definition
CSV (Comma-Separated Values) is a plain-text file format for storing tabular data — rows and columns — where each row is a line of text and columns are separated by commas. It is the most portable format for exchanging spreadsheet-like data between applications: virtually every database, spreadsheet application, and programming language can read and write CSV. Despite its simplicity, CSV has no formal standard, which leads to many variations in how special cases like commas in values and multiline fields are handled.
How It Works
Each line in a CSV file represents one data record (row). Fields are separated by a delimiter, most commonly a comma. If a field value contains the delimiter, a newline, or a double-quote, it must be enclosed in double quotes. A double-quote character inside a quoted field is escaped by doubling it (""). The first row often contains column headers, though this is a convention rather than a requirement. The RFC 4180 specification defines a standard for CSV, but many systems use semicolons or tabs as delimiters (the tab variant is called TSV).
Common Use Cases
- ▸Exporting database query results for analysis in Excel or Google Sheets
- ▸Importing bulk data into databases, CRMs, and marketing tools
- ▸Exchanging tabular datasets between data science tools like pandas and R
- ▸Storing configuration lists where each row is a simple record
- ▸Migrating data between systems when a shared schema is a flat table
Example
id,name,email,active 1,Alice,[email protected],true 2,Bob,"bob,[email protected]",true 3,Charlie,,false (Note: Bob's email is quoted because it contains a comma)
Related Tools
Convert CSV data to a JSON array of objects.
Convert a JSON array of objects to CSV format.
Convert CSV (comma-separated) to TSV (tab-separated) format.
Compare two CSV files row by row and highlight added, removed, and changed cells.
Upload and view CSV files as a formatted table.
FAQ
- What if my data contains commas?
- Fields that contain the delimiter (comma) must be enclosed in double quotes: "Smith, John". If the field also contains double quotes, each quote is doubled: "He said ""hello""".
- Why does my CSV look wrong when opened in Excel?
- Excel uses the system locale to determine the delimiter. In many European locales, Excel expects semicolons instead of commas because commas are used as decimal separators. Opening such a file requires changing the delimiter settings or saving it as a proper .xlsx file.
- What is the difference between CSV and TSV?
- TSV (Tab-Separated Values) uses tab characters as delimiters instead of commas. TSV is slightly safer for text data because text is less likely to contain tabs than commas, reducing the need for quoting.