DoneInTab
Technical Reference • Data Architecture

The Complete Guide to CSV & Excel Data Preservation

Understanding RFC 4180 standards, delimiter regional mismatches, leading-zero corruption, and OWASP spreadsheet injection defenses.

1. The Infamous Leading-Zero Problem: Why Excel Corrupts Your Data

One of the most persistent complaints among accountants, logistics coordinators, and software engineers is that opening a CSV file in Microsoft Excel strips leading zeros from identifiers.

Default Excel Behavior (Lossy)

Input CSV: 00501,000123456789

Excel converts cells to standard numbers: 501 and 123456789. Holtsville, NY ZIP code 00501 becomes an invalid 3-digit number.

Safe OpenXML Preservation (DoneInTab)

Output XLSX: 00501,000123456789

Cells are explicitly encoded as text in the OpenXML <sharedStrings> table. All digits, leading zeros, and telephone plus signs remain 100% intact.

When converting CSV to Excel, safe converters must never assume numbers should be coerced into floating-point values unless explicitly opted in by the user.

2. Delimiter Differences: Comma, Semicolon, and Tab

Despite the name “Comma Separated Values”, global spreadsheets rely on multiple delimiters based on local language formatting:

DelimiterCharacterCommon Geography & ContextDecimal Point Clashes
Standard Comma,United States, UK, Canada, AustraliaNone (Period . used for decimals)
Semicolon;Germany, France, Spain, BrazilRequired because comma , is the currency decimal mark
Tab (TSV)\tDatabase exports, bioinformatics, loggingHigh immunity to field punctuation collision
Pipe|Mainframe systems, healthcare EDI filesRare in natural text; very low collision rate

3. RFC 4180 Quoting and Multiline Rules

The Internet Engineering Task Force (IETF) codified CSV behavior in RFC 4180. The core principles include:

  • Embedded Commas: If a field contains a comma, semicolon, or delimiter character, the entire field must be enclosed in double quotes: "New York, NY".
  • Escaped Quotes: If a quoted field contains double quotes, they must be escaped by prefixing another double quote: "He said ""Hello"" to them".
  • Multiline Values: Cells containing hard line breaks (\r\n or \n) must be wrapped in double quotes. Naive line-by-line parsers (split('\n')) inevitably break on multiline cells.
  • UTF-8 Byte Order Mark (BOM): Prepending the 3-byte sequence \uFEFF signals to Windows Excel that the file contains UTF-8 Unicode characters rather than legacy Windows-1252.

4. Spreadsheet Formula Injection (OWASP CSV Injection)

Spreadsheet programs automatically evaluate cells that begin with formula trigger characters:

Dangerous Characters: =, +, -, @, \t, \r

If an untrusted user signs up with the first name =cmd|'/C calc'!A0 and an administrator exports the customer list to CSV, opening that file in Excel can execute arbitrary local system commands via Dynamic Data Exchange (DDE).

To defend against CSV injection, our tools offer an explicit sanitization option that prepends an apostrophe (') to suspicious cells. This forces the spreadsheet engine to display the formula as harmless literal text.

5. Free In-Browser Conversion Utilities

Apply these standards immediately using our 100% private, client-side spreadsheet tools, or read our step-by-step tutorials on keeping leading zeros in CSV files and opening and converting JSON files to Excel: