Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse Kaggle "toxic comments" dataset #2600

Closed
st-pasha opened this issue Jan 31, 2018 · 0 comments · Fixed by #2800
Closed

Unable to parse Kaggle "toxic comments" dataset #2600

st-pasha opened this issue Jan 31, 2018 · 0 comments · Fixed by #2800
Milestone

Comments

@st-pasha
Copy link
Contributor

This is the file (requires opening a Kaggle account and accepting ToS to download; cannot be shared freely):
https://www.kaggle.com/c/jigsaw-toxic-comment-classification-challenge/download/test.csv.zip

This file is well-formed, has 2 columns, uses , as sep, QR=1, and all fields are quoted. The only "problem" is that sometimes the fields are quite long (i.e. may contain more than 100 lines)... So this is what happens (with the latest data.table):

> fread("~/Downloads/jigsaw.test.csv")
Error in fread("~/Downloads/jigsaw.test.csv") : 
  Line 4 has too few fields. Expecting 2 fields but found 0. Consider fill=TRUE. First 500 characters of line: <<>>
> fread("~/Downloads/jigsaw.test.csv", fill=TRUE)
Error in fread("~/Downloads/jigsaw.test.csv", fill = TRUE) : 
  Line 29 has more than the expected 2 fields. Stopped on <<don't just>> at character 32. Consider setting 'comment.char=' if there is a trailing comment to be ignored. First 500 characters of line: << When fixing double redirects, don't just blank the outer one, you need edit it to point it to the final target, unless you think it's inappropriate, in which case, it needs to be nominated at WP:RfD">>
> fread("~/Downloads/jigsaw.test.csv", sep="")
Error in fread("~/Downloads/jigsaw.test.csv", sep = "") : 
  Internal error: first line has field count -1 but expecting 1

This is the verbose output:

> fread("~/Downloads/jigsaw.test.csv", verbose=T)
Input contains no \n. Taking this to be a filename to open
[01] Check arguments
  Using 8 threads (omp_get_max_threads()=8, nth=8)
  NAstrings = [<<NA>>]
  None of the NAstrings look like numbers.
  show progress = 1
  0/1 column will be read as boolean
[02] Opening the file
  Opening file /Users/pasha/Downloads/jigsaw.test.csv
  File opened, size = 57.56MB (60354593 bytes).
  Memory mapped ok
[03] Detect and skip BOM
[04] Arrange mmap to be \0 terminated
  \n has been found in the data so any mixture of line endings is allowed other than \r-only line endings. This is common and ideal.
[05] Skipping initial rows if needed
  Positioned on line 1 starting: <<"id","comment_text">>
[06] Detect separator, quoting rule, and ncolumns
  Detecting sep ...
  sep=','  with 100 lines of 2 fields using quote rule 0
  Detected 2 columns on line 1. This line is either column names or first data row. Line starts as: <<"id","comment_text">>
  Quote rule picked = 0
  fill=false and the most number of columns found is 2
[07] Detect column types, good nrow estimate and whether first row is column names
  Number of sampling jump points = 101 because (60354592 bytes from row 1 to eof) / (2 * 38167 jump0size) == 790
  Type codes (jump 000)    : AA  Quote rule 0
  Type codes (jump 012)    : AA  Quote rule 2
  Not using sample from jump 13. Looks like a complicated file where nextGoodLine could not establish the next true line start.
  Not using sample from jump 17. Looks like a complicated file where nextGoodLine could not establish the next true line start.
  Not using sample from jump 31. Looks like a complicated file where nextGoodLine could not establish the next true line start.
  Not using sample from jump 38. Looks like a complicated file where nextGoodLine could not establish the next true line start.
  Not using sample from jump 48. Looks like a complicated file where nextGoodLine could not establish the next true line start.
  Not using sample from jump 69. Looks like a complicated file where nextGoodLine could not establish the next true line start.
  'header' determined to be true because all columns are type string and a better guess is not possible
  =====
  Sampled 1285 rows (handled \n inside quoted fields) at 101 jump points
  Bytes from first data row on line 2 to the end of last row: 60354572
  Line length: mean=347.69 sd=539.09 min=5 max=5856
  Estimated number of rows: 60354572 / 347.69 = 173590
  Initial alloc = 347180 rows (173590 + 100%) using bytes/max(mean-2*sd,min) clamped between [1.1*estn, 2.0*estn]
  =====
[08] Assign column names
[09] Apply user overrides on column types
  After 0 type and 0 drop user overrides : AA
[10] Allocate memory for the datatable
  Allocating 2 column slots (2 - 0 dropped) with 347180 rows
[11] Read the data
  jumps=[0..64), chunk_size=943040, total_size=60354572
Error in fread("~/Downloads/jigsaw.test.csv", verbose = T) : 
  Line 4 has too few fields. Expecting 2 fields but found 0. Consider fill=TRUE. First 500 characters of line: <<>>

It should also be mentioned that read.csv() can read this file without any problems...

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

Successfully merging a pull request may close this issue.

2 participants