fjordtools / Errors / CSV: text after a closing quote

CSV: text after a closing quote

A quoted CSV value ends at the first quote that is not doubled, and only a delimiter or a line break may follow it. When something else follows, such as a letter, a space or a semicolon, the reader stops. Most often a quote inside the value was not written twice.

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

How browsers word it

Python csv, strict=True',' expected after '"'
Python csv, defaultNo error: the characters after the quote are kept in the value

Common causes

  1. A quote inside a quoted value

    The quote before hi ends the value early. The reader then finds the letter h where a comma should be.

    Input

    name,note
    Ann,"said "hi" to me"

    CSV JSON says

    Unexpected "h" after a closing quote in row 2, column 2 (line 2). A quoted field must end at the delimiter or the end of the line
  2. A space after the closing quote

    A space between the closing quote and the comma, often from hand-edited files, is text after the quote.

    Input

    name,note
    Ann,"a" b

    CSV JSON says

    Unexpected space after a closing quote in row 2, column 2 (line 2). A quoted field must end at the delimiter or the end of the line
  3. The wrong delimiter

    A file that uses semicolons, read as comma-separated, hits a semicolon right after the quote.

    Input

    name,note
    Ann,"Oslo"; Norway

    CSV JSON says

    Unexpected ";" after a closing quote in row 2, column 2 (line 2). A quoted field must end at the delimiter or the end of the line
  4. Quotes written twice

    Doubling each inner quote keeps the value in one piece.

    Input

    name,note
    Ann,"said ""hi"" to me"

    CSV JSON says

    [{"name":"Ann","note":"said \"hi\" to me"}]
  5. A quote in an unquoted value

    A quote inside a value that does not start with one is kept as a character. Inches work.

    Input

    name,note
    Ann,5" pipe

    CSV JSON says

    [{"name":"Ann","note":"5\" pipe"}]

How to fix it

  1. Write each quote inside a quoted value as two quotes: "said ""hi""".
  2. Remove spaces between a closing quote and the delimiter.
  3. Choose the delimiter the file really uses (comma, semicolon, tab or pipe) instead of Auto if detection guessed wrong.
  4. Let the program that writes the file do the quoting.
  5. Paste the text into the CSV JSON converter: it shows the character, row and line where the value broke.

Related errors

More error explainers are coming

See all errors.