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

skip _empty_rows = TRUE fails in vroom_fwf #501

Open
richardjtelford opened this issue Jun 23, 2023 · 1 comment
Open

skip _empty_rows = TRUE fails in vroom_fwf #501

richardjtelford opened this issue Jun 23, 2023 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@richardjtelford
Copy link

I'm having problems that appear to stem from vroom_fwf, and hence readr::read_fwf ignoring the skip_empty_rows argument.

Here is a minimal working example.

f <- "a b c

1 2 3

1 2 3"

readr::read_fwf(f, skip_empty_rows = TRUE, show_col_types = FALSE)
#> # A tibble: 5 × 3
#>   X1    X2    X3   
#>   <chr> <chr> <chr>
#> 1 a     b     c    
#> 2 <NA>  <NA>  <NA> 
#> 3 1     2     3    
#> 4 <NA>  <NA>  <NA> 
#> 5 1     2     3

vroom::vroom_fwf(I(f), skip_empty_rows = TRUE, show_col_types = FALSE)
#> # A tibble: 5 × 3
#>   X1    X2    X3   
#>   <chr> <chr> <chr>
#> 1 a     b     c    
#> 2 <NA>  <NA>  <NA> 
#> 3 1     2     3    
#> 4 <NA>  <NA>  <NA> 
#> 5 1     2     3

Created on 2023-06-23 with reprex v2.0.2

I was also expecting the column names to be a, b, c rather than X1, X2, X3, but that does not affect me now.

readr::read_table gives the expected result. Unfortunately I cannot easily switch to this as I am not calling the function directly but via another package.

@hadley
Copy link
Member

hadley commented Aug 1, 2023

FWIW that looks more like what we call tabular data, and read_table() does a better job with it:

f <- "a b c

1 2 3

1 2 3"

readr::read_table(f, skip_empty_rows = TRUE)
#> # A tibble: 2 × 3
#>       a     b     c
#>   <dbl> <dbl> <dbl>
#> 1     1     2     3
#> 2     1     2     3

Created on 2023-08-01 with reprex v2.0.2

@hadley hadley added the bug an unexpected problem or unintended behavior label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants