Read specific (non-consecutive) rows from csv
问题 I have a large csv file and would like to read only certain lines, defined by a vector of row numbers to be read. Is there any way to read these rows without reading the whole csv into memory? The only solutions I've found seem to allow reading consecutive lines (e.g. lines 2-100). 回答1: A simple example of how you might combine the sed approach I linked to into an R function: read_rows <- function(file,rows,...){ tmp <- tempfile() row_cmd <- paste(paste(rows,"p",sep = ""),collapse = ";") cmd