Skip to contents

Create a data.frame from a folder of non-rectangular excel files based on a defined custom template

Usage

xlsx_cutter(
  data_files,
  template_file,
  data_sheet = 1,
  template_sheet = 1,
  marker_open = "{{",
  marker_close = "}}"
)

Arguments

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_folder

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 data_folder

marker_open, marker_close

character marker to mark the variables to extract in the template_file

Value

A rectangular data.frame with columns as defined in the template. Column types are determined automatically by type.convert()

Examples


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
)
#>   employee_firstname contract_hours employee_lastname realised_hours
#> 1               Leon             35              Bedu          29.00
#> 2               Paul             35            Dupont          35.00
#> 3           Marianne             35            Lebrun          36.25
#>   manager_firstname manager_lastname period_start period_end
#> 1              <NA>           Dubois   2022-01-03 2022-01-07
#> 2             Lydia           Dubois   2022-01-03 2022-01-07
#> 3             Lydia           Dubois   2022-01-03 2022-01-07