A connection to the file filename is created. Column types have to be specified. These are not determined automatically as for example read.fwf does. This has been done to increase speed.
laf_open_fwf(
filename,
column_types,
column_widths,
column_names = paste("V", seq_len(length(column_types)), sep = ""),
dec = ".",
trim = TRUE,
ignore_failed_conversion = FALSE
)
Object of type laf
. Values can be extracted from this object
using indexing, and methods such as read_lines
, next_block
.
character containing the filename of the fixed width file.
character vector containing the types of data in each of the columns. Valid types are: double, integer, categorical and string.
numeric vector containing the width in number of character of each of the columns.
optional character vector containing the names of the columns.
optional character specifying the decimal mark.
optional logical specifying whether or not whitespace at the end of factor levels or character strings should be trimmed.
ignore (set to NA
) fields that could
not be converted.
After the connection is created data can be extracted using indexing (as in a normal data.frame) or methods such as read_lines and next_block can be used to read in blocks. For processing the file in blocks the (faster) convenience function process_blocks can be used.
Only use ignore_failed_conversion
when you are sure that the column
specification is correct. Otherwise, this option can hide an incorrect
specification.
See read.fwf
for conventional access of fixed width files.