Skip to content

Skip commented lines #381

@jennybc

Description

@jennybc

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

Metadata

Metadata

Assignees

Labels

featurea feature request or enhancement

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions