Repository navigation
Implement comment.char argument in fread #856
Description
Activity
Need to ignore whole lines (starting with comment) as well as trailing comments after valid lines.
Reacted by Marcelo C. R. Melo, Michael Chirico, Tokhir Dadaev, Artem Klevtsov, Laura DeCicco, Michael Steinbaugh and Arthur PéréThen update this question : http://stackoverflow.com/questions/18920777/fread-data-table-in-r/
Bump. Needing this right now.
Reacted by Michael Chirico, Jimmy O'Donnell, Malcolm Cook, Boxiang Liu, Tokhir Dadaev, Ufuk Kirik, Ben Bond-Lamberty, Niek de Klein, Artem Klevtsov, Steve Bronder and 2 moreActually
freadseem to assume it already has this implemented as it is mentioningcomment.charin its warnings. This is a warning I've recently saw (using the dev 1.10.5 version)Warning in fread(file_x, skip = startind - 1L, header = TRUE, fill = TRUE) :
Stopped early on line 2. Expected 168 fields but found 235. Consider fill=TRUE and comment.char=.Also, not sure why isn't this an error? It make it harder to catch it with
tryCatchReacted by yaakovfeldman, Tokhir Dadaev and matthewInteresting. Can you chase the comment and find an author and commit per
git blame?
I am mostly using the CRAN version so I work around the issue (when I have to, which is not that often).@eddelbuettel You can find it here https://github.com/Rdatatable/data.table/blame/master/src/fread.c#L2351
Thanks. Which one can click on for
git blameso yield ...Better skip= and nrow= (#2623)
by Matt just one day ago (!!)
12 remaining items
@ArthurPERE it is best to use a documentation as reference and defined behaviour. There you can also find there is no such a thing like
comment.charparameter. You can findfreadmanual at https://rdatatable.gitlab.io/data.table/library/data.table/html/fread.htmlAFAIR status of this FR or works on it are well reflected in comments. Be sure to upvote this FR so it will likely speed up its implementation, or at least prioritise. You are also welcome to submit a patch introducing such feature.
- addedtop requestOne of our most-requested issuesOne of our most-requested issuesand removed
on Jun 7, 2020 Following up on this, I'm open to helping develop and/or test this functionality in a future update
@mjsteinbaugh you are very welcome, please submit PR
Reacted by Michael SteinbaughThere is still that error message that references
comment.char:Warning in fread("vep_output") : Stopped early on line 4. Expected 6 fields but found 5. Consider fill=TRUE and comment.char=. First discarded non-empty line: <<## Using cache in /home/dgealow/.vep/homo_sapiens/113_GRCh38>>This is incredibly confusing since comment.char is not a parameter to fread. If there are no plans to actually implement it any time soon (I notice this ticket has been open for 10 years) I'd suggest removing the reference from that error message.
Reacted by Aaron RobothamWe have a pending PR: #4486. It requires some love to get it over the line :)
Reacted by Ben Bond-Lamberty, Michael Steinbaugh and Dan Gealow- added a commit that references this issue
on May 22, 2026
Similar to
read.table.