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

read_csv produce empty columns when first rows are NA #124

Closed
artemklevtsov opened this issue Apr 12, 2015 · 2 comments
Closed

read_csv produce empty columns when first rows are NA #124

artemklevtsov opened this issue Apr 12, 2015 · 2 comments

Comments

@artemklevtsov
Copy link

@artemklevtsov artemklevtsov commented Apr 12, 2015

Hi.

Thanks for the package. It's really nice.

I have data when first 100+ rows are empty. readr can't parse this cols as expected.

To reproduce:

library(readr)

df <- data.frame(A = rep(c(NA, 1:3), each = 100, times = 2),
                 B = rep(c(NA, "A", "B", each = 200)))

temp_file <- tempfile(fileext = ".csv")
write_csv(df, temp_file)

df2 <- read_csv(temp_file)
head(problems(df2))
#> row col       expected actual
#> 1 101   1 T/F/TRUE/FALSE      1
#> 2 102   1 T/F/TRUE/FALSE      1
#> 3 103   1 T/F/TRUE/FALSE      1
#> 4 104   1 T/F/TRUE/FALSE      1
#> 5 105   1 T/F/TRUE/FALSE      1
#> 6 106   1 T/F/TRUE/FALSE      1

lapply(df, table)
#> $A
#> 
#>   1   2   3 
#> 200 200 200 
#> 
#> $B
#> 
#> 200   A   B 
#> 200 200 200 
lapply(df2, table)
#> $A
#> < table of extent 0 >
#> 
#> $B
#> 
#> 200   A   B 
#> 200 200 200 
@hadley
Copy link
Member

@hadley hadley commented Apr 13, 2015

Yes, in this scenario you'll need to either specify skip = 100, or manually supply the column types.

@hadley hadley closed this Apr 13, 2015
@artemklevtsov
Copy link
Author

@artemklevtsov artemklevtsov commented Apr 13, 2015

I have file with 50+ cols and about 1k rows. I need not skip a rows because other columns not contains NAs. It's too hard to suuply a types for 50 columns.

As result read_csv can't correctly read the file.

hadley added a commit that referenced this issue Apr 16, 2015
Closes #124. Closes #128.
@lock lock bot locked and limited conversation to collaborators Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants