MyNixOS website logo
Description

Parse Batches of 'xlsx' Files Based on a Template.

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.

xlcutter

License:MIT R-CMD-check Codecov testcoverage lifecycle-concept

This package allows you to 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.

Installation

You can install the latest stable version of this package from CRAN:

install.packages("xlcutter")

or the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("Bisaloo/xlcutter")

Example

Non-rectangular excel files are common in many domains. For a simple demonstration here, we use the example of the “Blue timesheet” from https://templates.office.com/, where employees can log their working hours.

A typical use case of xlcutter in this example would be for a manager who want to get a single rectangular dataset with the timesheets from different employees.

Screenshot of timesheets from two fictitiousemployees

Your first step to extract the data is to define the various columns you want in the output in a template file. You can mark the data cells to extract with any custom marker, with the default being {{ column_name }}.

Screenshot of a template for the timesheetexample

library(xlcutter)

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

Other example of use cases

Other typical use cases for this package could be:

  • an hospital that wants to collate non-rectangular information sheets from different patients into a single rectangular dataset.
Metadata

Version

0.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows