Skip to content

fread fails to parse quotation mark as first character of field  #1256

Closed

Description

@RuinedSubmartingale

Consider the following files:
file1.csv

x,y
x1,"oops" y1

file2.csv

x,y
x1, "oops" y1

file3.csv

x,y
"oops" x1,y1

file4.csv

x,y
 "oops" x1,y1

Running fread('file2.csv') and fread('file4.csv') run smoothly. But fread('file1.csv') throws the following error:

Field 2 on line 2 starts with quote (") but then has a problem. It can contain balanced unescaped quoted subregions but if it does it can't contain embedded \n as well. Check for unbalanced unescaped quotes: "oops" y1

And fread('file3.csv') throws a similar error:
Error in fread("testfile.csv") :

Field 1 on line 2 starts with quote (") but then has a problem. It can contain balanced unescaped quoted subregions but if it does it can't contain embedded \n as well. Check for unbalanced unescaped quotes: "oops" x1,y1

The only difference between the two pairs of files is that file1 and file3 have fields that begin with a " character, whereas there's a space before the " in the fields for file2 and file4. Recent changes to fread seem to have caused this error in v1.9.5, seeing as how v1.9.4 is able to parse all 4 files smoothly.

Activity

  1. changed the title [-]fread fails to parse quote immediately after separator [/-] [+]fread fails to parse quotation mark as first character of field [/+] on Aug 10, 2015
  2. added this to the v1.9.6 milestone on Sep 7, 2015
  3. arunsrinivasan commented on Sep 8, 2015

    @arunsrinivasan
    Member

    Thanks for the report. quote = "" is implemented. Either use that, or create your file with "" around character columns so that quote = "\"" can then read it properly. See ?fread quote argument.

  4. arunsrinivasan commented on Sep 16, 2015

    @arunsrinivasan
    Member

    Removed quote argument with a better fix (slightly more robust) for quotes. Please upgrade and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions