fdply: Read some chunks from a file into a 'data.table'

View source: R/fdply.R

fdplyR Documentation

Read some chunks from a file into a data.table

Description

This function is useful to quickly glance at a big chunked file. It is similar to the head() function, except that it does not read the first few lines, but rather the first few blocks of the file. By default, only the first block will be read; it is not advisable to read a large number of blocks in this way because they may occupy a lot of memory. The blocks are saved to a data.table. See ?fplyr for the definitions of chunked file and block.

Usage

fdply(
  input,
  nblocks = 1,
  key.sep = "\t",
  sep = "\t",
  skip = 0,
  colClasses = NULL,
  header = TRUE,
  stringsAsFactors = FALSE,
  select = NULL,
  drop = NULL,
  col.names = NULL,
  parallel = 1
)

Arguments

input

Path of the input file.

nblocks

The number of blocks to read.

key.sep

The character that delimits the first field from the rest.

sep

The field delimiter (often equal to key.sep).

skip

Number of lines to skip at the beginning of the file

colClasses

Vector or list specifying the class of each field.

header

Whether the file has a header.

stringsAsFactors

Whether to convert strings into factors.

select

The columns (names or numbers) to be read.

drop

The columns (names or numbers) not to be read.

col.names

Names of the columns.

parallel

Number of cores to use.

Value

A data.table containing the file truncated to the number of blocks specified.

Slogan

fdply: from file to data.table


fplyr documentation built on Aug. 24, 2023, 1:08 a.m.