How browsers word it
| Python csv, strict=True | ',' expected after '"' |
|---|---|
| Python csv, default | No error: the characters after the quote are kept in the value |
Common causes
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
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
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
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"}]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
- Write each quote inside a quoted value as two quotes: "said ""hi""".
- Remove spaces between a closing quote and the delimiter.
- Choose the delimiter the file really uses (comma, semicolon, tab or pipe) instead of Auto if detection guessed wrong.
- Let the program that writes the file do the quoting.
- Paste the text into the CSV JSON converter: it shows the character, row and line where the value broke.