CSV error: unclosed quoted field (EOF inside string)

In CSV, a field that starts with a double quote continues until the next lone double quote, and it may span several lines. When that closing quote is missing, the parser keeps reading through the rest of the file looking for it, and either reaches the end (“EOF inside string”) or builds one giant field (Python’s “field larger than field limit”). The real mistake is on the row where the quoted field starts, which PasteKit highlights.

Seen as:

  • pandas.errors.ParserError: Error tokenizing data. C error: EOF inside string starting at row 1
  • _csv.Error: unexpected end of data
  • _csv.Error: field larger than field limit (131072)
  • Quoted field unterminated
  • CSV::MalformedCSVError: Unclosed quoted field in line 2.

Input

Settings

History

Load from URL

Common causes

1. A missing closing quote

A field opened with " but never closed swallows every following row. Add the closing quote at the end of the value.

Before
id,name,comment
1,Ada,"Great service
2,Grace,Late delivery
After
id,name,comment
1,Ada,"Great service"
2,Grace,Late delivery

2. Quotes inside a quoted field escaped with a backslash

CSV escapes a quote inside a quoted field by doubling it (""), not with \". MySQL SELECT INTO OUTFILE and some hand-written exporters use backslashes, which standard readers misread as the end of the field.

Before
id,quote
1,"He said \"hi\""
After
id,quote
1,"He said ""hi"""

3. A quote character used as inches or a typographic mark

A field that begins with a quote, like "27" monitor, is read as a quoted field that ends after 27. Quote the whole value and double the inner quote.

Before
id,size,note
1,"27" monitor",ok
After
id,size,note
1,"27"" monitor",ok

4. A file truncated in the middle of a quoted field

Downloads and exports that stop early can cut a multi-line quoted field in half. Re-export the file, or remove the incomplete last row.

Before
id,notes
1,"Shipped
2,"Pending review
After
id,notes
1,"Shipped"
2,"Pending review"

Frequently asked questions

Why does pandas report a row far from the problem?

The “starting at row” number is where the unclosed quoted field began, counted from the first data row in some versions. Everything after it was swallowed into that field, so the start row is the one to inspect.

Can I tell pandas to ignore quotes?

Passing quoting=csv.QUOTE_NONE makes quotes ordinary characters, which avoids the error but splits any quoted field that contains a comma. Fixing the quoting in the source is safer.

Are line breaks allowed inside CSV fields?

Yes, inside a quoted field. That is exactly why an unclosed quote is so disruptive: the parser has no way to know the line break was not meant to be part of the value.

Related