fwrite_fwf: Fast write a fixed-width file.

Description Usage Arguments Value See Also Examples

Description

fwrite_fwf takes as basic input a data.table and the schema for the fwf file to write, concatenates columns accordingly and uses fwrite to write the file on disk.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
fwrite_fwf(
  data,
  filename,
  StfwfSchema,
  validate = FALSE,
  justify = "left",
  ...
)

## S4 method for signature 'data.frame,character,StfwfSchema'
fwrite_fwf(
  data,
  filename,
  StfwfSchema,
  validate = FALSE,
  justify = "right",
  ...
)

Arguments

data

data.table with the data to write.

filename

Character vector of length 1 with the name of the file to write.

StfwfSchema

Object of class StfwfSchema with the schema of the file.

validate

Logical vector of length 1 with default value FALSE to indicate whether to validate the content of data before writing.

justify

Character vector of length 1 with default value left to indicate whether to justify strings to the left or to the right.

...

Other parameters from fwrite.

Value

Returns an invisible NULL. The dataset is written in file filename.

See Also

fwrite fread_fwf]

Examples

1
2
3
4
5
6
7
8
## Not run: 
# file will be written to working directory
path <- system.file('extdata', package = 'fastReadfwf')
stSchema <- fastReadfwf::xlsxToSchema(file.path(path, 'SchemaSNHS.xlsx'), 'stSchema')
data(MicroDataSNHS)
fwrite_fwf(MicroDataSNHS, file.path(getwd(), 'MicroDataSNHS'), stSchema, justify = 'right')

## End(Not run)

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