fjordtools / Errors / CSV: unclosed quoted field

CSV: quoted field is never closed

A value in the CSV starts with a double quote, and the file ends before a closing quote appears. A quoted value may run over several lines, so the reader keeps going to the end and finds nothing to close it. Find the line the quote opened on, then close the value or remove the stray quote.

Fjordtools team · Seen in CSV files from spreadsheets, databases and exports · Published · 2 min read

How browsers word it

Python csv, strict=Trueunexpected end of data
Python csv, defaultNo error: the rest of the file becomes one value

Common causes

  1. A quote that opens and never closes

    The value for Ann starts with a quote, so the reader treats the next line break and everything after it as part of that value, up to the end of the file.

    Input

    name,note
    Ann,"unclosed
    Bob,ok

    CSV JSON says

    Quoted field is never closed. The quote opened in row 2, column 2 (line 2) has no closing quote
  2. A file that was cut off

    An interrupted download or export can stop in the middle of a quoted value. The last line then has an opening quote and no end.

    Input

    id,note
    1,"a note that
    was cut

    CSV JSON says

    Quoted field is never closed. The quote opened in row 2, column 2 (line 2) has no closing quote
  3. Quotes doubled inside a value

    To put a quote inside a quoted value, write it twice. The reader turns each pair into one quote.

    Input

    name,note
    Ann,"said ""hi"""

    CSV JSON says

    [{"name":"Ann","note":"said \"hi\""}]
  4. A line break inside a closed value

    A line break inside a pair of quotes is fine. It is part of the value, not the end of the row.

    Input

    name,note
    Ann,"line1
    line2"

    CSV JSON says

    [{"name":"Ann","note":"line1\nline2"}]

How to fix it

  1. Go to the line named in the message and add the missing closing quote, or delete the quote if the value was never meant to be quoted.
  2. Write a quote inside a quoted value as two quotes: "".
  3. If the file was cut off, export or download it again.
  4. Let the program that writes the file do the quoting instead of joining text by hand.
  5. Paste the text into the CSV JSON converter: it names the row, column and line where the unclosed quote starts.

Related errors

More error explainers are coming

See all errors.