Learn R Programming

parimport (version 0.0.5)

rlchunk: read a flat file specifying first and last records to import

Description

read a flat file specifying first and last records to import

Usage

rlchunk(fspec, start, end, confun = gzfile, txfun=NULL)

Arguments

fspec
character string specifying location and name of flat file
start
first record for import
end
last record for import
confun
connection function such as gzfile or file
txfun
if non-null, function that will be applied to each line of the chunk read

Value

Details

opens connection with open="r"

Examples

Run this code
gfspec = system.file("gz/demo.txt.gz", package="parimport")
fspec = system.file("txt/demo.txt", package="parimport")
rlchunk( gfspec, 3, 7 )
rlchunk( fspec, 2, 4, file )
mytx = function(recs) sapply(recs, 
   function(rec) strsplit(rec, "")[[1]][2], USE.NAMES=FALSE)
rlchunk( gfspec, 3, 7, txfun=mytx )

Run the code above in your browser using DataLab