fread error on specific CSV

Open
#5,110 6 comments 0 reactions 1 assignee View on GitHub

@ben-schwen is already working on this.

Since Oct 23, 2025.

Assessment

This issue has not been assessed yet.

Description

fread

# [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

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.