validateValues: Fast read a fixed-width file

Description Usage Arguments Value Examples

Description

fread_fwf takes as basic input a fixed-width filename and its schema and wraps around fread from package data.table to provide the contents of the file.

This method is indeed a wrapper for the function fread followed by the application of stri_sub.

Usage

1
2
3
4
validateValues(object, StfwfSchema, perl = FALSE)

## S4 method for signature 'data.frame,StfwfSchema'
validateValues(object, StfwfSchema, perl = FALSE)

Arguments

object

Object with rectangular shape whose columns will be validated.

StfwfSchema

Object of class StfwfSchema with the schema of object.

perl

Logical vector of length 1 with default value FALSE to indicate whether to use perl or not in the application of regexp.

Value

Returns TRUE.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
path <- system.file('extdata', package = 'fastReadfwf')
stSchema <- fastReadfwf::StxlsxToSchema(
   file.path(path, 'SchemaSNHS.xlsx'),
   sheetToRead = 'stSchema')

# For data.tables
data <- fread_fwf(
file.path(path, 'MicroDataSNHS.txt'), stSchema, outFormat = 'data.table', perl = TRUE)
validateValues(data, stSchema, perl = TRUE)

# For tibbles
data <- fread_fwf(
file.path(path, 'MicroDataSNHS.txt'), stSchema, outFormat = 'tibble')
validateValues(data, stSchema, perl = TRUE)

david-salgado/fastReadfwf documentation built on Dec. 25, 2021, 12:43 p.m.