f_write_data_to_file_merged: Reads files, appends data and writes merged file

View source: R/f - Write data to file merged.R

f_write_data_to_file_mergedR Documentation

Reads files, appends data and writes merged file

Description

Reads, appends and writes data to merged file. Function looks for files with same core name in folder - usually only the date (and time) differs. The files can be filtered on their age (number of days). Only files older than n.day.max are merged and written to a new file. New data can be appended through df.input. The files that were merged are moved to an Archive\ folder.

Usage

f_write_data_to_file_merged(
  df.input,
  c.path,
  c.file.string,
  c.file.type,
  c.sheet.name = "Sheet1",
  v.add.date = TRUE,
  v.add.time = FALSE,
  n.day.max = 1e+06
)

Arguments

df.input

Data frame with data to append to merged data,

c.path

Path where file(s) are searched for.

c.file.string

Core of the filename of the files to be merged. The same is used for the file that is written.

c.file.type

File type of files to merge. The merged file will also be saved in this format.

c.sheet.name

Sheetname containing the data to be merged. Is relevant in case of c.file.type being xls (default: "Sheet1").

v.add.date, v.add.time

Vector of booleans to specify whether data and/or time should be added. This should be as long as x (default: TRUE and FALSE, resp.).

n.day.max

Files newer than the number of days given in n.day.max are merged. The high default value essentially means that all files are merged (default: 1000000).

Details

-

Value

Boolean whether the vector contains unique values.

Author(s)

Pieter Overdevest

Examples

f_write_data_to_file_merged(

     df.input       = mtcars,
     c.path         = path.data,
     c.file.string  = "dummy file",
     c.sheet.name   = "Sheet1",
     c.file.type    = "xls",
     v.add.date     = TRUE,
     v.add.time     = FALSE,
     n.day.max      = 1000000
)

pieterov/generaltoolbox documentation built on Jan. 25, 2025, 10:32 a.m.