What Is a .csv File?
A .csv file is a simple way of storing tabular data as plain text. It is commonly used to move information between spreadsheets, databases, websites and software applications.
CSV means Comma-Separated Values
CSV stands for Comma-Separated Values.
A .csv file stores data as plain text, usually with each line representing a row and commas separating the individual values within that row.
This makes CSV particularly useful for information that naturally fits into rows and columns.
What does CSV data look like?
Imagine a spreadsheet containing customer information:
The first line contains the column headings. Each line after that represents one record.
| Name | Orders | |
|---|---|---|
| Alice | alice@example.com | 4 |
| Ben | ben@example.com | 7 |
| Carla | carla@example.com | 2 |
The CSV file and the table contain essentially the same information. The difference is how that information is represented.
Rows, columns and values
Rows
Each line normally represents one record, such as one customer, one product or one transaction.
Columns
Each position within a row represents a particular field, such as a name, price or date.
Delimiter
Commas normally separate the fields from one another, giving the format its name.
Header row
Many CSV files begin with a row containing the names of the columns, although this is not compulsory.
A CSV file is still a text file
CSV is a structured text format.
If you open a CSV file in a plain-text editor, you can normally read its contents directly.
However, spreadsheet software such as Microsoft Excel or Google Sheets can interpret the separators and display the information as rows and columns.
What happens if the data itself contains a comma?
Sometimes a value needs to contain a comma of its own. In that situation, the value can be enclosed in double quotation marks.
The quotation marks tell software that the comma inside the location belongs to the value rather than separating two different columns.
What about quotation marks inside a value?
If a quoted field itself contains a double quotation mark, CSV commonly represents it by doubling the quotation mark.
This allows the quotation mark to remain part of the actual data.
A CSV file is not an Excel workbook
Excel can open CSV files, but that does not make CSV an Excel format.
A normal Excel workbook can store much more than simple tabular values. It can contain formatting, formulas, multiple worksheets, charts and other spreadsheet features.
| Feature | CSV | Excel workbook |
|---|---|---|
| Rows and columns | Yes | Yes |
| Plain text | Yes | No |
| Multiple worksheets | No | Yes |
| Cell formatting | No | Yes |
| Charts | No | Yes |
Important: when an Excel workbook is exported to CSV, features such as colours, fonts, charts and multiple worksheets are not preserved as part of the CSV format.
Why is CSV so widely used?
Simple
CSV has a straightforward structure that is relatively easy for both people and software to understand.
Portable
CSV files can move data between many different applications and operating systems.
Lightweight
There is very little additional information surrounding the actual data.
Programmable
Programming languages and data tools can easily read, create and transform CSV files.
What are CSV files used for?
CSV files are common anywhere structured data needs to move from one system to another.
CSV and UTF-8
Like other text files, a CSV file must use a character encoding.
UTF-8 is a particularly useful choice because it supports a huge range of characters and languages.
Important: the .csv extension does not itself guarantee UTF-8. The character encoding is a separate property of the file.
Is a comma always used?
CSV literally means Comma-Separated Values, and commas are the standard delimiter associated with the format.
In practice, however, data files may also use other separators. For example, semicolons are sometimes used because of regional settings or software conventions.
Files using tabs as separators are commonly called TSV, meaning Tab-Separated Values.
Why CSV matters in data management
CSV is particularly useful because it provides a simple bridge between different systems.
A database can export records to CSV. A spreadsheet can open them. A script can transform them. Another application can then import the resulting file.
This makes CSV extremely useful for data migration, cleaning, imports, exports and automation.
How is CSV different from TXT?
Both .txt and .csv files can contain plain text.
The key difference is that CSV normally follows a tabular structure: values are separated into fields and records so that software can interpret them as rows and columns.
A general .txt file does not necessarily have that structure.
| Format | Main purpose |
|---|---|
| .txt | General plain-text information |
| .csv | Structured tabular data |
Simple text. Structured data.
A .csv file stores tabular information as plain text, normally using commas to separate values and new lines to separate records. Its simplicity makes CSV one of the most useful formats for exchanging data between spreadsheets, databases, websites and software systems.