You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fread's nrow argument could accept -ve values to skip last 'n' rows #1643
Yeah, I could use this. I'm currently reading in csvs that often have an incomplete last line (not enough fields as inferred from commas), which reliably causes fread to crash R.
It would be nice to set skip.last=1L to avoid this. Because nrow already allows a negative value as Michael mentioned, I think it would be cleaner as a separate arg or allowing the skip arg to have a length of two (with the second component of the vector taking on this role when present).
I would prefer the way mentioned by Arun, as it would be consistent to linux head and tail way of handling negative values. If negative skip is currently being used, and cannot be easily changed, then it make sense to allow skip of length two, so skip=c(0, 1) would skip just the last line.
Just for completeness current workaround: fread("head -n -1 filename.csv")
Reacted by Frank, Michael Chirico, Artem Klevtsov and Yuri Dias
On a related note, it would be nice if we could pass a list of indicies (also as part of the 'skip' parameter) to explicitly read in the rows you want, like we can do in python's Pandas. If the list of indicies is random, it is a nice way to create a random sample of a data frame which is too large to be read onto a local machine, for instance.
could be useful for this post: http://stackoverflow.com/q/36558437/559784