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 commented lines #381

Closed
jennybc opened this Issue Mar 12, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@jennybc
Member

jennybc commented Mar 12, 2016

I expected the read.csv() behaviour (TBH I'm surprised about the lack of NAs there).

library(readr)

mat <- matrix(
  c(paste0("thing", 1:3),
    "A2", "B2", "C2",
    "A3", "#B3", "C3",
    "#A4", "B4", "C4",
    "A5", "*", "C5"),
  byrow = TRUE, ncol = 3)
row_txt <- apply(mat, 1, paste, collapse = ",")
txt <- paste(row_txt, collapse = "\n")

read_csv(txt)
#> Source: local data frame [4 x 3]
#> 
#>   thing1 thing2 thing3
#>    (chr)  (chr)  (chr)
#> 1     A2     B2     C2
#> 2     A3    #B3     C3
#> 3    #A4     B4     C4
#> 4     A5      *     C5
read.csv(text = txt)
#>   thing1 thing2 thing3
#> 1     A2     B2     C2
#> 2     A3    #B3     C3
#> 3    #A4     B4     C4
#> 4     A5      *     C5

read_csv(txt, comment = "#")
#> Warning: 1 parsing failure.
#> row col  expected    actual
#>   2  -- 3 columns 4 columns
#> Source: local data frame [2 x 3]
#> 
#>   thing1 thing2 thing3
#>    (chr)  (chr)  (chr)
#> 1     A2     B2     C2
#> 2     A3     A5      *
read.csv(text = txt, comment.char = "#")
#>   thing1 thing2 thing3
#> 1     A2     B2     C2
#> 2     A3              
#> 3     A5      *     C5

@hadley hadley changed the title from Embedded comments confuse things to Ignore comments inside quotes Jun 1, 2016

@hadley

This comment has been minimized.

Member

hadley commented Jun 1, 2016

Hmmm, not sure what's going wrong here, but I'd expect these two calls to return the same thing:

read_csv("x1,x2,x3\nA2,B2,C2\nA3,#B3,C3\n#A4,B4,C4\nA5,*,C5", comment = "#")
read_csv("x1,x2,x3\nA2,B2,C2\nA3\n#A4,B4,C4\nA5,*,C5", comment = "#")

@hadley hadley changed the title from Ignore comments inside quotes to Ensure comment generates same warnings for missing columns Jun 2, 2016

@hadley hadley changed the title from Ensure comment generates same warnings for missing columns to Ignore comments inside quotes Jun 2, 2016

jimhester added a commit to jimhester/readr that referenced this issue Jul 8, 2016

@jimhester jimhester added in progress and removed ready labels Jul 8, 2016

@hadley hadley modified the milestone: 0.3.0 Jul 13, 2016

@hadley hadley changed the title from Ignore comments inside quotes to Skip commented lines Jul 13, 2016

jimhester added a commit to jimhester/readr that referenced this issue Jul 13, 2016

@hadley hadley closed this in #459 Jul 13, 2016

hadley added a commit that referenced this issue Jul 13, 2016

Comment parsing bug when there is a line with nothing but comments (#459
)

* Comment parsing bug when there is a line with nothing but comments

* Add line variable to warnings / tokenizer

Fixes #381. Fixes #321.

@hadley hadley removed the in progress label Jul 13, 2016

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018

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