Key facts
- Loosely standardised by RFC 4180: fields containing commas, quotes or line breaks are wrapped in double quotes, and a quote inside a field is written as two quotes.
- MIME type is text/csv.
- CSV has no data types, so dates, long numbers and values with leading zeros are interpreted by whatever app opens the file.
- European Excel locales export with semicolons because the comma is their decimal separator.
- Encoding is not stored in the file; UTF-8 with or without a byte-order mark (BOM) and Windows-1252 are the most common.
How to open a .csv file
In Excel use Data > From Text/CSV so you can choose the delimiter and encoding instead of double-clicking. Notepad or VS Code shows the raw text.
Open it with Numbers or Excel, or use File > Import in Excel to set the delimiter. TextEdit or any code editor shows the raw text.
Open it in LibreOffice Calc, which shows an import dialog for delimiter and character set, or view it with column -s, -t < file.csv | less -S.
Common problems and fixes
- Everything appears in one column in Excel
- The file's delimiter does not match your regional list separator, for example a semicolon file on a US system or vice versa. Import via Data > From Text/CSV and pick the right delimiter, or convert the file to a consistent comma-delimited CSV.
- Accented letters show as é or other garbage
- The file is UTF-8 but was opened as Windows-1252, or the reverse. Re-import choosing UTF-8 (65001), or re-save the file as UTF-8 with a BOM so Excel detects it.
- Leading zeros, long IDs or dates are changed
- Excel converts values like 00123 or 1234567890123456 to numbers or scientific notation. Import the file and set those columns to Text instead of double-clicking it.
- Rows are split or columns shift partway through the file
- A field contains a comma or line break without proper quoting, or has an unescaped double quote. Fix the quoting at the source, or locate the bad line by counting fields per row.
- Cells starting with =, +, - or @ run as formulas
- Spreadsheets treat these as formulas, which attackers abuse for CSV injection. Prefix such cells with a single quote or neutralise them before opening untrusted exports.
Often converted to or from: XLSX, JSON, SQL, TSV, XML, Markdown table