chunk_reader {CIMICE} | R Documentation

## Gradually read a file from disk

### Description

This function creates a reader to read a text file in batches (or chunks). It can be used for very large files that cannot fit in RAM.

### Usage

    chunk_reader(file_path)

### Arguments

`file_path` | path to large file

### Value

a list-object containing the function 'read' to read lines from the given file, and 'close' to close the connection to the file stream.

### Examples

    # open connection to file
    reader <- chunk_reader(
        system.file("extdata", "paac_jhu_2014_500.maf", package = "CIMICE", mustWork = TRUE)
    )

    while(TRUE){
        # read a chunk
        chunk <- reader$read(10)
        if(length(chunk) == 0){
            break
        }
        # --- process chunk ---
    }
    # close connection
    reader$close()

[Package CIMICE version 1.2.1 Index]