LHTSOFT Learn · Understand the why

How to open an untrusted CSV without spreadsheet surprises

CSV is plain-text tabular data, not a safe or universal spreadsheet format. The same file can be interpreted differently by a spreadsheet, a database and a program. Imported text may be automatically converted into dates, scientific notation or executable formulas.

Treat suspicious cells as text

Spreadsheet programs may interpret cell values beginning with characters such as =, +, - or @ as formulas under some configurations. A malicious value may be buried in a row that looks like ordinary contact data. Do not enable external links or macros from an untrusted attachment; review the source and import it as text where possible.

Protect identifiers and dates

A postal code such as 00123 is an identifier, not the number 123. Import that column explicitly as text. Dates like 03/04/2026 depend on locale conventions. For interchange, agree on ISO dates such as 2026-04-03 where suitable and document the intended timezone and meaning of blanks.

Understand quoting and encoding

CSV commonly uses quotes around fields containing commas or line breaks, and represents an embedded quote by two quote characters. A UTF-8 file may still display incorrectly when opened by software assuming a different encoding. Choose the encoding during import rather than repeatedly saving a corrupted interpretation.

Validate with a harmless fixture

Create a tiny test CSV with a quoted comma, a leading-zero identifier, an ordinary date and a formula-looking string that is never executed. Inspect it as raw text first. Import every column deliberately as text and compare the displayed strings. Do not open a real malicious formula in a spreadsheet just to see what happens.

Build a safe test record

  1. Save the text header id,name,note, then a row with 00123,"Lee, Ana","Check date 2026-04-03".
  2. View the file in a plain-text editor: verify that the comma inside the quoted name does not divide the name into two columns.
  3. Use a spreadsheet's text/CSV import wizard and mark the id column as text.
  4. Verify that 00123 remains five characters, not 123, and that the full name stays together.

A correct import preserves each intended string; this controlled example does not execute formulas or test a potentially malicious workbook.