Skip to content

read_csv errors if a column name is blank and cols() explicitly names an existing column name #318

Description

@cjyetman
csv <- "v1,v2,v3,v4,\n1,2,3,4,"
read_csv(csv)
read_csv(csv, col_types = "iiiii")
read_csv(csv, col_types = cols(.default = "c"))
read_csv(csv, col_types = cols(v1 = col_integer()))

all work as expected, except the last read which results in:

Error: not compatible with STRSXP

yes, CSVs with a final column with no data exist in the wild, ex. subset ESS data exported from the ESS Cumulative Data Wizard (European Social Survey)

R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] readr_0.2.2

loaded via a namespace (and not attached):
[1] rsconnect_0.4.1.4 tools_3.2.2       Rcpp_0.12.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions