Skip to content

In read_sheet, can't import blank cells as empty string #174

@dulearnaux

Description

@dulearnaux

Specifying na explicitly to not convert the default value of "" to NA, still converts "" to NA's once read into R.

I have created a public spread sheet( 1dyCsWgVu72w3yYA6BdmFDqMTrf2OBxawwD_ZBPN7JF8) containing:
https://docs.google.com/spreadsheets/d/1dyCsWgVu72w3yYA6BdmFDqMTrf2OBxawwD_ZBPN7JF8

col1 col2 col3
1 a NA
2 b missing
3 c
4 d hello
5 e w
gsheet_id <-"1dyCsWgVu72w3yYA6BdmFDqMTrf2OBxawwD_ZBPN7JF8"
googlesheets4::read_sheet(gsheet_id, na = c("NA", "missing"))

#> Reading from "googlesheets4_bug"
#> Range "Sheet1"
#> # A tibble: 5 x 3
#>    col1 col2  col3 
#>   <dbl> <chr> <chr>
#> 1     1 a     NA   
#> 2     2 b     NA   
#> 3     3 c     NA   
#> 4     4 d     hello
#> 5     5 e     w    

Was expecting similar behaviour to readr, where "" is retained.

csv_txt <- "col1,col2,col3
1,a,NA
2,b,missing
3,c,
4,d,hello
5,e,w"

readr::read_delim(csv_txt, na = c("missing", "NA"), delim = ",")
#> # A tibble: 5 x 3
#>    col1 col2  col3   
#>   <int> <chr> <chr>  
#> 1     1 a      NA    
#> 2     2 b      NA    
#> 3     3 c     ""     
#> 4     4 d     "hello"
#> 5     5 e     "w"    

Metadata

Metadata

Assignees

No one assigned

    Labels

    types 🏭Cell and column types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions