Title: | Parse Batches of 'xlsx' Files Based on a Template |
---|---|
Description: | Parse entire folders of non-rectangular 'xlsx' files into a single rectangular and tidy 'data.frame' based on a custom template file defining the column names of the output. |
Authors: | Hugo Gruson [aut, cre, cph] |
Maintainer: | Hugo Gruson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1.9000 |
Built: | 2024-12-06 04:40:50 UTC |
Source: | https://github.com/Bisaloo/xlcutter |
xlsx_cutter()
Validate an xlsx template file to use in xlsx_cutter()
validate_xltemplate( template_file, template_sheet = 1, marker_open = "{{", marker_close = "}}", minimal = FALSE, error = FALSE )
validate_xltemplate( template_file, template_sheet = 1, marker_open = "{{", marker_close = "}}", minimal = FALSE, error = FALSE )
template_file |
path to the template file to use as a model to parse the
xlsx files in |
template_sheet |
sheet id of the template file to use as a model to
parse the xlsx files in |
marker_open , marker_close
|
character marker to mark the variables to
extract in the |
minimal |
Logical (default to |
error |
Logical (defaults to |
TRUE
if the template is valid, FALSE
otherwise
# Valid template validate_xltemplate( system.file("example", "timesheet_template.xlsx", package = "xlcutter") ) # Invalid templates validate_xltemplate( system.file("example", "template_duped_vars.xlsx", package = "xlcutter") ) validate_xltemplate( system.file("example", "template_fluff.xlsx", package = "xlcutter"), minimal = TRUE )
# Valid template validate_xltemplate( system.file("example", "timesheet_template.xlsx", package = "xlcutter") ) # Invalid templates validate_xltemplate( system.file("example", "template_duped_vars.xlsx", package = "xlcutter") ) validate_xltemplate( system.file("example", "template_fluff.xlsx", package = "xlcutter"), minimal = TRUE )
Create a data.frame from a folder of non-rectangular excel files based on a defined custom template
xlsx_cutter( data_files, template_file, data_sheet = 1, template_sheet = 1, marker_open = "{{", marker_close = "}}" )
xlsx_cutter( data_files, template_file, data_sheet = 1, template_sheet = 1, marker_open = "{{", marker_close = "}}" )
data_files |
vector of paths to the xlsx files to parse |
template_file |
path to the template file to use as a model to parse the
xlsx files in |
data_sheet |
sheet id to extract from the xlsx files |
template_sheet |
sheet id of the template file to use as a model to
parse the xlsx files in |
marker_open , marker_close
|
character marker to mark the variables to
extract in the |
A rectangular data.frame
with columns as defined in the template.
Column types are determined automatically by type.convert()
data_files <- list.files( system.file("example", "timesheet", package = "xlcutter"), pattern = "\\.xlsx$", full.names = TRUE ) template_file <- system.file( "example", "timesheet_template.xlsx", package = "xlcutter" ) xlsx_cutter( data_files, template_file )
data_files <- list.files( system.file("example", "timesheet", package = "xlcutter"), pattern = "\\.xlsx$", full.names = TRUE ) template_file <- system.file( "example", "timesheet_template.xlsx", package = "xlcutter" ) xlsx_cutter( data_files, template_file )