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

add comment arg to read_table #563

Closed
wants to merge 1 commit into from
Closed

add comment arg to read_table #563

wants to merge 1 commit into from

Conversation

@cboettig
Copy link
Contributor

@cboettig cboettig commented Dec 6, 2016

tokenizer_fwf already has an option for comment, but for some reason this seems to have been omitted from read_table, though it is present in all other read_ methods (and in read.table()). Adding it back here.

tokenizer_fwf already has an option for comment, but for some reason this seems to have been omitted from read_table, though it is present in all other `read_` methods (and in `read.table()`).  Adding it back here.
@hadley
Copy link
Member

@hadley hadley commented Dec 28, 2016

This will also need to be fed in to fwf_empty()

@jimhester
Copy link
Member

@jimhester jimhester commented Jan 23, 2017

Thanks! The repo this PR comes from seems to have gone off into the nether, but I re-created your commit manually (d65b23d) with Hadley's suggestion.

@jimhester jimhester closed this Jan 23, 2017
@cboettig
Copy link
Contributor Author

@cboettig cboettig commented Feb 3, 2017

@jimhester apologies, it looks like my commit didn't actually fix the issue so I removed it. That change allows read_table to take a comment arg, but it is effectively ignored and so the function still chokes trying to parse commented white-space delimited tables. I guess that is why it was omitted in the first place, looks like something will have to be changed lower down to skip comment symbols on read_table.

Here's a reproducible example (from a classic data set):

read_table("ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt", 
                  comment = "#)
@jimhester
Copy link
Member

@jimhester jimhester commented Feb 3, 2017

As of 7ab8634 this show now work properly

library(readr)
read_table("ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt",
  comment = "#", col_names = FALSE)
#> cols(
#>   X1 = col_integer(),
#>   X2 = col_integer(),
#>   X3 = col_double(),
#>   X4 = col_double(),
#>   X5 = col_double(),
#>   X6 = col_double(),
#>   X7 = col_integer()
#> )
#> # A tibble: 706 × 7
#>       X1    X2       X3     X4     X5     X6    X7
#>    <int> <int>    <dbl>  <dbl>  <dbl>  <dbl> <int>
#> 1   1958     3 1958.208 315.71 315.71 314.62    -1
#> 2   1958     4 1958.292 317.45 317.45 315.29    -1
#> 3   1958     5 1958.375 317.50 317.50 314.71    -1
#> 4   1958     6 1958.458 -99.99 317.10 314.85    -1
#> 5   1958     7 1958.542 315.86 315.86 314.98    -1
#> 6   1958     8 1958.625 314.93 314.93 315.94    -1
#> 7   1958     9 1958.708 313.20 313.20 315.91    -1
#> 8   1958    10 1958.792 -99.99 312.66 315.61    -1
#> 9   1958    11 1958.875 313.33 313.33 315.31    -1
#> 10  1958    12 1958.958 314.67 314.67 315.61    -1
#> # ... with 696 more rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants