Skip to content

fread error on specific CSV #5110

@kmichelson

Description

@kmichelson

# [Minimal reproducible example]

I first downloaded a list of federal grants: https://exporter.nih.gov/CSVs/final/RePORTER_PRJ_C_FY2016.zip
The path to the extracted file was placed in the variable csvfile

  csvdata<-fread(csvfile,colClasses="character")

I then get the following warning that stops further reading:

1: In fread(csv, colClasses = "character") :
  Stopped early on line 42369. Expected 46 fields but found 38. Consider fill=TRUE and comment.char=. First discarded non-empty line: <<"100239","","AF","","","","09/30/2016","09/29/2021","n/a","","N/A","","HHSP233201500059I/HHSP23337002T","ACF:5356081\","","2016","Administration for Children and Families","","NEW YORK","UNITED STATES","N/A","12","075258780","US","1633601","MDRC","NY","100164328","",";  (contact); ","BURCHINAL, MARGARET; HSUEH, JOANN  (contact);","MARTINEZ-BECK, IVELISSE","09/30/2016","09/29/2021","early care and education quality improvement; quality of ECE ; child outcomes; preschool-aged children; implementat>>

When I opened the CSV in Excel, it had no trouble loading, and I could not detect any issues with the line. Even if there is a problem with the CSV line itself, fread should at least gracefully handle the problem and move on. Thanks for considering the issue.

# Output of sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] lubridate_1.7.10 bit64_4.0.5 bit_4.0.4 stringr_1.4.0 data.table_1.14.0

loaded via a namespace (and not attached):
[1] compiler_4.1.0 magrittr_2.0.1 generics_0.1.0 tools_4.1.0 Rcpp_1.0.6 tinytex_0.31
[7] stringi_1.6.2 xfun_0.23

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions