Description Usage Arguments Value See Also Examples
View source: R/INExlsxToSchema.R
INExlsxToSchema
transforms an xlsx file in the Spanish NSI internal standard
for fwf schemas into an object with class StfwfSchema.
This function reads an Excel file containing the schema of the fixed-width file to read according to the Spanish NSI internal standard, creates an intermediate xml file with the information of the schema, reads this xml file and constructs an object of class StfwfSchema. The intermediate xml file contains the following elements:
variable
: the name of the variable.
width
: the number of positions which the values of this variable occupy in the
fwf file.
initialPos
: initial position of the field which the values of this variable
occupy in the fwf file.
finalPos
: final position of the field which the values of this variable occupy in
the fwf file.
type
: type of the variable. It must be either log
, integer
,
num
or char
.
valueRegEx
: regular expression for the values of this variable.
description
: textual description of the variable.
The Excel file must have a header in the second row (according to Spanish NSI internal standard)..
1 2 3 4 5 6 | INExlsxToSchema(
xlsxName,
sheetToRead = 1,
xmlName = NULL,
regionName = "METADATOS"
)
|
xlsxName |
Complete name of the xlsx file containing the schema. |
sheetToRead |
Name or index of the sheet of the schema in the xlsx file. |
xmlName |
Complete name where the xml file is going to be written. |
regionName |
Region from the xlsx file containing the info about the number of rows. |
Return an object of class StfwfSchema.
1 2 3 4 | path <- 'inst/extdata'
xlsxName <- file.path(system.file('extdata', package = 'fastReadfwf'), 'dr_EESEadulto_2020.xlsx')
xmlName <- file.path(system.file('extdata', package = 'fastReadfwf'), 'dr_EESEadulto_2020.xml')
stSchema <- INExlsxToSchema(xlsxName = xlsxName, xmlName = xmlName)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.