Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Tolerate blank lines ... at least at the end of input? #321
library(readr) input <- "x,y\n1,2\n\n" read.csv(text = input) #> x y #> 1 1 2 read_csv(input) #> Warning: 1 parsing failure. #> row col expected actual #> 2 -- 2 columns 1 columns #> Source: local data frame [2 x 2] #> #> x y #> (int) (int) #> 1 1 2 #> 2 NA NA read_csv(trimws(input)) #> Source: local data frame [1 x 2] #> #> x y #> (int) (int) #> 1 1 2
It seems reasonable to tolerate and ignore blank lines ... at least at the end of the input.
Yeah, I think that's totally reasonable (and for empty lines anywhere, not just at the end). It's just a little tricky to implement because you need to think more about what line numbers to report in error messages etc - the original line numbers, or the row numbers in the generated data frame.