CSV commas in invoice descriptions: quoting

A comma inside a CSV field stays text only if the field is in double quotes. Quote invoice descriptions, double inner quotes, keep empty apart from 0.

See the PDF-to-Excel example

A comma inside a CSV field is kept as text only when the whole field is enclosed in double quotes, as in "Widget, size M", and a double quote inside that field is written twice (""). If Excel still splits an invoice description into extra columns, the file was written without that quoting or opened with the wrong delimiter, so fix the export or the import settings, not the description.

These rules come from RFC 4180, section 2: fields containing commas, double quotes or line breaks should be enclosed in double quotes, and an inner double quote is escaped by a second one. Quoting settles structure only. A description that starts with = raises a separate risk, covered in CSV formula injection in supplier descriptions.

How do you escape a comma in a CSV field?

Enclose the field, not the comma. For the description Widget, size “M”:

Source textCorrect CSV fieldCommon mistake
Widget, size M"Widget, size M"Widget\, size M (backslash is not CSV escaping)
Widget, size "M""Widget, size ""M""""Widget, size \"M\""
Seal + line break + black"Seal / black" on two physical linesTwo separate records

A complete synthetic record is INV-7,"Widget, size ""M""",2,12.50. It has four fields: invoice, description, quantity and line net amount.

A semicolon-delimited file is a different dialect. Spreadsheets in decimal-comma locales often save CSV with semicolons, so 12,50 is not split. Whoever exports and whoever imports must agree on the delimiter explicitly; a decimal comma does not define it.

Why does Excel split a description into extra columns?

Three causes cover most cases:

  1. The field is not quoted. The exporter wrote Widget, size M without quotes, so every reader sees two fields. Fix the export.
  2. The delimiter does not match. The file uses semicolons but the import expects commas, or the reverse: the whole record lands in one column, or columns shift.
  3. The quotes were serialized twice. The description shows ""M"" after import: the text was quoted again by a second export step.

To check, open the file in a plain text editor first, then import a copy with the spreadsheet’s text/CSV import, choose the delimiter used in the file and check the preview before loading. Do not split a whole file on commas or replace every quote globally: use a parser configured for the agreed dialect.

InvoiceLineLab extracts invoice line items from PDF to Excel or CSV and keeps each description in one field, wrapped lines included, beside its quantity and amounts. The synthetic example and its CSV show that structure.

How do you keep a multiline description in one record?

Here is a fictional comma-delimited file from one vendor (supplier). The last field is the line net amount, in EUR.

invoice,line,description,quantity,line_net
INV-8,1,"Kit, ""M""",2,25.00
INV-8,2,"Seal
black",3,24.00

The expected result is two item records with five fields each. The first description is the literal text Kit, "M"; the second contains “Seal”, a line break and “black”, with quantity 3 and line net 24.00. The header plus three physical data lines do not represent three purchases. Implied unit prices are 25.00 / 2 = 12.50 and 24.00 / 3 = 8.00; the net sum is 49.00.

Compare the field count of the header with every parsed record, not the number of text lines. If a continuation appears as a separate item, or the quotes remain doubled, stop and inspect the parser settings and the original file. Do not delete the continuation to force the row count. When a receiver cannot keep multiline fields, add a documented single-line description beside the original instead of changing the source text.

Can a row have the right field count and still be wrong?

Yes. A row with five fields can still have its business meanings swapped. In the example, also check that quantities 2 and 3 did not move into the amount column and that 25.00 and 24.00 still belong to their lines. Reconcile both the record count and the values field by field.

Symptom after importFirst thing to inspectAcceptance condition
Entire record in one columnDelimiter settingEach named field has its own column
Extra column after a description commaQuoting in the exportThe whole description stays in one field
Inner quotes still doubledDouble serializationOne literal quote where the source has one
Description continuation becomes an itemMultiline field supportBoth text lines stay in the same record
Last amount missingTrailing fields and empty-field handlingThe final field keeps its position
Structure correct, accents alteredEncodingSource text survives decoding unchanged

For the last symptom, see CSV UTF-8 in Excel for accented descriptions. These symptoms guide investigation; they are not automatic repair rules. Replacing commas with semicolons globally would change descriptions and decimals along with the separators.

Is an empty CSV field the same as zero?

No. Consider the synthetic record INV-9,3,"Seal, black",,0.00: invoice INV-9, line 3, one description, an empty quantity and a line net of 0.00. Two consecutive delimiters mean an empty field; they do not justify shifting the zero into the quantity or inventing a quantity of one.

Confirm the zero against the invoice: a 100% line discount can bring the net to zero, while an empty field may mean the value was not printed. Agree any null convention with the recipient rather than inferring it from punctuation. A useful handoff note names the encoding, delimiter, quote character, header row, column order, line ending (RFC 4180 describes CRLF between records), the treatment of empty fields and the meaning of each amount column. “CSV for Excel” specifies none of these.

FAQ

How do you put a comma in a CSV field?

Enclose the whole field in double quotes: "Widget, size M". A backslash before the comma does not work in standard CSV.

How do you write a double quote inside a CSV field?

Double it inside a quoted field: "size ""M""" is read as size "M".

Why does my CSV open in one column in Excel?

The file’s delimiter differs from the one Excel expects, often semicolon versus comma. Import it and choose the delimiter explicitly.

Is an empty field the same as zero in a CSV?

No. Empty means no value was written; 0.00 is a printed zero. Keep the distinction until the invoice explains it.

Continue the checks

Amounts in the same file follow their own convention: see Excel decimal separators in invoice amounts. Keep descriptions on line items rather than invoice header fields.

InvoiceLineLab turns supplier invoice lines into reviewable spreadsheet rows. Download the fictional invoice CSV to test your delimiter settings, and see the invoice data validation checks.

Sources and further reading

Get started with InvoiceLineLab

Enter your work email to get access to InvoiceLineLab. No account or payment is created at this stage.

Submitting sends your email and visit context to our publisher’s infrastructure, named on the Privacy page. No account, payment or automatic email is triggered. Privacy.