Skip to content

read_csv produce empty columns when first rows are NA #124

Description

@artemklevtsov

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 

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions