CSV
CSV
The simplest tabular data format, separating columns with commas
Introduction
CSV (Comma-Separated Values) is simple tabular text in which each line is a row and the comma-separated values are the columns. It is the most common way to exchange tabular data between spreadsheets and databases.
Its structure is flat, so it cannot hold hierarchical data, but that same simplicity makes it lightweight and openable anywhere.
Syntax Features
- The first line is often used as a header (column names).
- If a value contains a comma, quote, or line break, it is wrapped in double quotes.
- A quote inside quotes is escaped by doubling it ("").
- A semicolon or tab is sometimes used as the delimiter.
Pros
- Opens anywhere, including Excel and databases
- Lightweight and simple
- Efficient for large tabular data
Cons
- Cannot express hierarchical or nested data
- No type information, so everything is a string
- Many delimiter and encoding dialects
Common Uses
- Spreadsheet export and import
- Datasets for data analysis
- Database bulk loading
Example
id,name,role
1,Ada,admin
2,Linus,editor