SheetPeek

CSV vs XLSX: which format should you use?

8 min readUpdated September 2026
Two data files side by side on a desk with a notebook

CSV and XLSX both hold rows and columns, and for a small table either will do. The differences show up the moment your data contains leading zeros, dates, long identifiers, non-Latin text or more rows than a worksheet can hold. Understanding what each format physically is — a line of text versus a compressed package of XML documents — explains almost every surprise you will meet, and makes the choice between them straightforward.

What each format actually is

A CSV file is plain text. Each line is a record, fields are separated by a delimiter, and a field containing the delimiter, a quote or a line break is wrapped in double quotes with internal quotes doubled. That convention is described by RFC 4180, published in 2005 — but it documents common practice rather than mandating it, which is why real-world CSV files vary in delimiter, quoting style and line endings. There is no header in the file declaring any of those choices.

An XLSX file is a ZIP archive. Rename one to .zip, unpack it, and you will find a directory tree of XML documents defined by the Office Open XML standard (ECMA-376, later ISO/IEC 29500): `xl/workbook.xml` lists the sheets, `xl/worksheets/sheet1.xml` holds the cells, `xl/sharedStrings.xml` stores every distinct text value once, and `xl/styles.xml` holds fonts, fills and number formats that cells reference by index.

That structural difference drives everything else. CSV carries values and nothing more, so it is readable by any tool that can read a line of text. XLSX carries values plus types, formatting, formulas, multiple sheets and metadata, so it needs a library that understands the standard — but it can express things CSV simply has no place to put.

Types, precision and formatting

In a CSV every field is text. `00123`, `2026-03-01` and `1.5e9` are strings until something decides otherwise, and that decision is made by the reader, not the file. This is the root cause of the classic losses: postal codes and account numbers stripped of leading zeros, product codes turned into dates, and sixteen-digit identifiers rendered as `1.23457E+15` because the reader parsed them as floating-point numbers.

XLSX is explicit. A cell declares its type in the XML: `t="s"` points into the shared string table, `t="b"` is boolean, and a bare numeric cell is a double. Dates are stored as serial numbers — days since 30 December 1899 in the default 1900 system — and rendered by a number format held in styles.xml. Because the type travels with the value, a round trip through XLSX does not silently change `00123` into `123`.

Two caveats. Both formats store numbers as IEEE 754 doubles, so neither is safe for values needing more than about 15 significant digits — keep credit card numbers, IMEIs and long external IDs as text. And the date serial system has the famous 29 February 1900 quirk, inherited from Lotus 1-2-3, which makes dates before March 1900 off by one day.

Encodings, BOMs and mojibake

A CSV file contains no declaration of its character encoding. The reader has to guess, and guessing wrong turns “Müller” into “Müller” or Cyrillic text into a wall of question marks. Files exported by older Windows software are often in a legacy code page such as Windows-1252 or Windows-1251 rather than UTF-8, which is where most mojibake originates.

The usual workaround is a UTF-8 byte order mark: three bytes (EF BB BF) at the start of the file that signal the encoding to Excel. It works, but it is a hint rather than a standard, and it leaks into naive parsers as an invisible prefix on the first column name — a common cause of a header that mysteriously will not match.

XLSX has no such problem. Its internal XML parts are UTF-8 by definition, so accented characters, Cyrillic, Greek, Arabic and CJK text survive unchanged no matter which locale wrote or read the file. If your data is multilingual and passes through people rather than pipelines, this alone is a strong argument for XLSX.

Size and speed

Intuition says plain text is smaller, and on disk it often is not. XLSX is deflate-compressed and stores repeated text once in the shared string table, so a file with many repeated categories can be several times smaller than the equivalent CSV. A CSV with high-cardinality numeric data usually wins the other way. Compress the CSV with gzip and it almost always wins outright.

Reading speed is a clearer story. CSV can be parsed as a stream: read bytes, split, emit rows, never hold the whole file. XLSX must first be unzipped, then its XML parsed and the shared string table resolved, and the archive’s central directory has to be read before anything else — so the whole workbook is effectively decoded in one piece. On large files CSV is reliably faster to load and far lighter on memory.

And the hard ceiling matters: a worksheet holds at most 1,048,576 rows and 16,384 columns, so a result larger than that cannot be written to XLSX at all. CSV has no row limit of its own — the limit is whatever reads it.

Interoperability and tooling

CSV is the lingua franca of data movement. Every database has a bulk loader for it, every language reads it without a dependency, and every ETL tool speaks it. It also works with the Unix toolchain — `grep`, `cut`, `sort`, `awk` and `split` all operate on it directly — and it diffs line by line in Git, which makes small reference tables genuinely reviewable in a pull request.

XLSX is the lingua franca of people. It carries multiple sheets, column widths, frozen panes, number formats, cell comments, data validation, conditional formatting, charts and live formulas — everything that makes a file usable as a document rather than as a payload. A finance team asked for “the numbers” expects a workbook, not a text file.

There is a security dimension too. XLSX can embed macros (in its .xlsm sibling) and external data connections, and it is a routine malware vector, so many organisations block or sandbox incoming workbooks. CSV has no executable content — though it is not entirely innocent either: a field starting with `=`, `+`, `-` or `@` can be interpreted as a formula by a spreadsheet, the CSV injection issue, which is why exports should prefix such values.

Gotchas that bite in practice

The delimiter is locale-dependent. In countries where the comma is the decimal separator — much of Europe, including Germany, France and Russia — Excel writes and expects semicolon-separated files while still calling them CSV. A file that opens perfectly for your colleague in Berlin may land in a single column for you, and vice versa. Always check the first line before you trust a parse.

Embedded line breaks are the other classic. A quoted field may legally contain a newline, so counting lines with `wc -l` overstates the row count and any parser that splits on `\n` without tracking quotes will corrupt the file. Multi-line addresses and free-text comment columns are where this shows up most often.

Finally, beware the round trip. Opening a CSV in Excel and saving it again rewrites the data according to Excel’s inference and your locale: dates get reformatted, leading zeros vanish, decimal separators change and the encoding may switch. If a CSV is an interface between systems, do not let a spreadsheet be a step in the pipeline — inspect it in a viewer that shows values as they are stored instead.

Which one to use

Choose CSV for machine-to-machine transfer, for anything above a few hundred thousand rows, for data going into a database or a data pipeline, for files that should live in version control, and whenever streaming or command-line processing matters. Write it as UTF-8, quote every field that needs it, use a comma, and state the delimiter and encoding in whatever documentation accompanies the export.

Choose XLSX when a person is the recipient, when types and formatting must survive the trip, when the deliverable needs several sheets or live formulas, or when the data is multilingual and you cannot control how it will be opened. Keep it under the worksheet limits and remember that the file is a document, with all the review and versioning habits that implies.

A pattern worth adopting: keep the authoritative dataset as CSV or Parquet, and generate XLSX as a rendered view for people when they ask for one. The source stays lossless, streamable and diffable, while the audience still gets the formatted workbook they expect.

Related toolSheetPeek workspaceOpen a CSV, Excel or JSON file — nothing is uploaded