You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src= paste(c("A,B",
paste(rep("1,2", 100), collapse="\n"),
"999",
paste(rep("3,4", 10000), collapse="\n"),
""),
collapse="\n") # taken from test 1822
fread(src)
# Error in fread(src) :# Expecting 2 cols but row 0 contains only 1 cols (sep=','). Consider fill=true. <<999>>
The row number should be 102, not 0.
It would also be nice to replace row by line (for consistency with other error messages) and true by TRUE.
Output of verbose = TRUE
Input contains a \n or is "". Taking this to be text input (not a filename)
[01] Check arguments
Using 4 threads (omp_get_max_threads()=4, nth=4)
NAstrings = [<<NA>>]
None of the NAstrings look like numbers.
show progress = 1
0/1 column will be read as boolean
[02] Opening the file
`input` argument is provided rather than a file name, interpreting as raw text to read
[03] Detect and skip BOM
[04] Arrange mmap to be \0 terminated
\r-only line endings are not allowed because \n is found in the data
[05] Skipping initial rows if needed
Positioned on line 1 starting: <<A,B>>
[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: <<A,B>>
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 = 11 because (40408 bytes from row 1 to eof) / (2 * 400 jump0size) == 50
'header' determined to be true due to column 1 containing a string on row 1 and a lower type (bool8) on row 2
Type codes (jump 000) : 15 Quote rule 0
Type codes (jump 001) : 55 Quote rule 0
Type codes (jump 010) : 55 Quote rule 0
=====
Sampled 1049 rows (handled \n inside quoted fields) at 11 jump points
Bytes from first data row on line 1 to the end of last row: 40408
Line length: mean=4.00 sd=0.00 min=4 max=4
Estimated number of rows: 40408 / 4.00 = 10102
Initial alloc = 11112 rows (10102 + 9%) 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 : 55
[10] Allocate memory for the datatable
Allocating 2 column slots (2 - 0 dropped) with 11112 rows
[11] Read the data
jumps=[0..1), chunk_size=40408, total_size=40404
[12] Finalizing the datatable
Read 100 rows x 2 columns from 39.46KB (40408 bytes) file in 00:00.001 wall clock time
Thread buffers were grown 0 times (if all 1 threads each grew once, this figure would be 1)
Final type counts
0 : drop
0 : bool8
0 : bool8
0 : bool8
0 : bool8
2 : int32
0 : int64
0 : float64
0 : float64
0 : float64
0 : string
sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.10.5
loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2
The text was updated successfully, but these errors were encountered:
mattdowle
changed the title
[fread] Wrong line number in error message
Wrong line number in error message
Oct 18, 2017
Uh-oh, after my long comment on your other #2428 just now, here, just seen this one. Ok, lets see.
> src = paste(c("A,B",
+ paste(rep("1,2", 100), collapse="\n"),
+ "999",
+ paste(rep("3,4", 10000), collapse="\n"),
+ ""),
+ collapse="\n") # taken from test 1822
> fread(src)
A B
1: 1 2
2: 1 2
3: 1 2
4: 1 2
... snip ...
97: 1 2
98: 1 2
99: 1 2
100: 1 2
A B
Warning message:
In fread(src) :
Stopped early on line 102. Expected 2 fields but found 1. Consider fill=TRUE and
comment.char=. First discarded non-empty line: <<999>>
Phew. So yes it say 102 now, TRUE in capitals, and, it does its best and returns data up to that line too (with warning) so you don't have to use nrows= yourself afterwards, if by good chance, stopping early is what you wanted. Otherwise just ignore the data returned and fix as appropriate. If in production you never want warnings, you'll be using options(warn=2) anyway to apply the no-warnings-in-production principle to all your code. That's my full current thinking, anyway.
Using dev version:
The row number should be 102, not 0.
It would also be nice to replace
row
byline
(for consistency with other error messages) andtrue
byTRUE
.Output of
verbose = TRUE
sessionInfo()
The text was updated successfully, but these errors were encountered: