Reputation: 135
I am reading a dataset where there are commented lines. I want to read the data from the dataset except the commented lines.
I tried using this but it only removes the comments on top not all the commented lines in between the dataset.
Code
txt = readLines("offline.txt")
txt = txt[4:length(txt)
Upvotes: 0
Views: 75
Reputation: 101678
I think you can try the code below, using grep
+ readLines
txt<-grep("^#",
readLines("offline.txt"),
invert = TRUE,
value = TRUE)
where the idea behind is that you read all lines first and then filter out the commented lines (starting with #
)
Upvotes: 1