Skip to contents

Save data as a .csv format file with semicolon ; as seperator. The file will be saved to the specified folder in path or as in Access regstration database with the root as in getOption("orgdata.folder.data"). Use argument save = TRUE in make_file() will activate save_file() directly. Else you can call save_file() to save the object output from make_file(). This function is a wrapper to data.table:fwrite().

Usage

save_file(
  dt = NULL,
  name = NULL,
  path = NULL,
  date = FALSE,
  fgSpec = NULL,
  sep = ";",
  ...
)

lagre_fil(
  dt = NULL,
  name = NULL,
  path = NULL,
  date = FALSE,
  fgSpec = NULL,
  sep = ";",
  ...
)

Arguments

dt

Input data preferrably in a data.table format but is not mandatory

name

Filename for the .csv file or filegroup name

path

Folder path to save the file. If name is a valide filegroup (FILGRUPPE) then use the specified UTMAPPE in Access registration database else file will be saved in default folder C:\Users\YourUserName\orgdata_logs. The default folder will be created if not exist.

date

Logical value. If TRUE then use date and time as part of the filename. Default is FALSE.

fgSpec

File group specification from Access registration database

sep

The separator between columns. Default is ";"

...

Other arguments for data.table::fwrite

Examples

if (FALSE) { # \dontrun{
 # Save file directly
 make_file("BEFOLKNING", save = TRUE)

 # Two steps
 DF <- make_file("BEFOLKNING")
 save_file(DF, "BEFOLKNING")

 # Save with different name and specified folder
 save_file(DF, name = "myCSVfile", path = "C:/MyFolder")
} # }