Skip to content

Error in fread{data.table} when reading txt files #801

@carlopacioni

Description

@carlopacioni

I'm trying to read a txt file using fread{data.table) but I get an error:

# (Error in fread(filename, h = F, sep = ";", nrows = 81, skip = 168, verbose = T) : 
# ' ends field 1 on line 168 when detecting types: Iteration 27)

The file is available here. The code is:

filename="test.txt"
require(data.table)
tyr <- fread(filename, h=F, sep=";", nrows=81, skip=168, verbose=T)

I can read the file fine with:

tyr <- fread(filename, h=F, sep=";", nrows=15, skip=168, verbose=T)

and I can read the file fine if I open it in a text editor (Notepad++), cut the first 167 lines, re-save it as plain txt and use:

tyr <- fread(filename, h=F, sep=";", nrows=81, skip=1, verbose=T)

Lastly, I can read the file fine using the equivalent call with read.table. I don't understand what fread is looking in line 168 since I said to skip it. The file is a standard output file from a software and each data block is identically formatted, yet I can read the previous data block fine with:

tyr <- fread(filename, h=F, sep=";", nrows=81, skip=86, verbose=T)

I'd appreciate any help in understanding what's going on.

Thanks, carlo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions