Read lines from a fileSource:
vroom_lines() is similar to
readLines(), however it reads the lines
vroom(), so operations like
can be done much more efficiently without reading all the data into R.
vroom_lines( file, n_max = Inf, skip = 0, na = character(), skip_empty_rows = FALSE, locale = default_locale(), altrep = TRUE, altrep_opts = deprecated(), num_threads = vroom_threads(), progress = vroom_progress() )
Either a path to a file, a connection, or literal data (either a single string or a raw vector).
Files ending in
.zipwill be automatically uncompressed. Files starting with
ftps://will be automatically downloaded. Remote gz files can also be automatically downloaded and decompressed.
Literal data is most useful for examples and tests. To be recognised as literal data, the input must be either wrapped with
I(), be a string containing at least one new line, or be a vector containing at least one string with a new line.
Maximum number of lines to read.
Number of lines to skip before reading data. If
commentis supplied any commented lines are ignored after skipping.
Character vector of strings to interpret as missing values. Set this option to
character()to indicate no missing values.
Should blank rows be ignored altogether? i.e. If this option is
TRUEthen blank rows will not be represented at all. If it is
FALSEthen they will be represented by
NAvalues in all the columns.
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use
locale()to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.
Control which column types use Altrep representations, either a character vector of types,
vroom_altrep()for for full details.
Number of threads to use when reading and materializing vectors. If your data contains newlines within fields the parser will automatically be forced to use a single thread only.
Display a progress bar? By default it will only display in an interactive session and not while knitting a document. The automatic progress bar can be disabled by setting option
lines <- vroom_lines(vroom_example("mtcars.csv")) length(lines) #>  33 head(lines, n = 2) #>  "model,mpg,cyl,disp,hp,drat,wt,qsec,vs,am,gear,carb" #>  "Mazda RX4,21,6,160,110,3.9,2.62,16.46,0,1,4,4" tail(lines, n = 2) #>  "Maserati Bora,15,8,301,335,3.54,3.57,14.6,0,1,5,8" #>  "Volvo 142E,21.4,4,121,109,4.11,2.78,18.6,1,1,4,2" sample(lines, size = 2) #>  "Fiat X1-9,27.3,4,79,66,4.08,1.935,18.9,1,1,4,1" #>  "Porsche 914-2,26,4,120.3,91,4.43,2.14,16.7,0,1,5,2"