The fastReadfwf package provides a standardised wrapper for functions
fread
and read_fwf
from packages
data.table and readr.
The premise is the construction of a standardised schema to read each file. This schema is essentially a data matrix with columns:
variable: the name of the variable.
width: the number of positions which the values of this variable occupies in the file.
initialPos: initial position of the field whic hthe values of this variable occupies in the file.
finalPos: final position of the field whic hthe values of this variable occupies in the file.
type: type of the variable. It must be either num
or char
.
valueRegEx: regular expression for the values of this variable.
description: textual description of the variable.
This standardised schema is implemented as an S4 class called StfwfSchema with constructors based on different input file formats (xlsx, csv, ...) specified by the user.
The package provides different getters and setters for objects of this class.
The core functions of the package, apart from the class management functions, are:
fread_fwf
, to read fixed-width files returning either
data.tables or tibble
s.
validateValues
, to validate the value of each variable in the fixed-width
file according to the regular expressions specified in the standardised schema.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.