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

Possible issue with fill in fread #1503

Closed
mrdwab opened this issue Jan 17, 2016 · 1 comment
Closed

Possible issue with fill in fread #1503

mrdwab opened this issue Jan 17, 2016 · 1 comment
Assignees
Milestone

Comments

@mrdwab
Copy link

mrdwab commented Jan 17, 2016

It's exciting to see that fread has gained some features that were previously slated as not-likely-to-be-implemented, for instance fill.

However, it seems like fread(..., fill = TRUE) is not happy when the first line is shorter than the longest row.

Using 1.9.7, obviously:

library(data.table)
packageVersion("data.table")
# [1] ‘1.9.7’

Simplest demonstration:

fread("1,a,b\n2", fill = TRUE)
#    V1 V2 V3
#1:  1  a  b
#2:  2      

fread("2\n1,a,b", fill = TRUE)
# Error in fread(paste(invec, collapse = "\n"), ...) : 
#   Unexpected character ending field 1 of line 1: 2
#1,a,

fread("v1,v2,v3\n2\n1,a,b", fill = TRUE)
#    v1 v2 v3
#1:  2      
#2:  1  a  b

Notice that by adding the column names in to the dataset itself, there is no problem with a shorter first row. So, I thought that using the col.names argument would help out in a situation like this. Unfortunately, it doesn't.

fread("2\n1,a,b", fill = TRUE, col.names = paste0("V", 1:3))
# Error in fread("2\n1,a,b", fill = TRUE, col.names = paste0("V", 1:3)) : 
#   Unexpected character ending field 1 of line 1: 2
#1,a,

Hope this is enough information to reproduce the behavior on your side too. Wanted to keep the samples simple :-)

@arunsrinivasan
Copy link
Member

Just back from vacation. Thanks @mrdwab.

@arunsrinivasan arunsrinivasan self-assigned this Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants