copy_pi_data: Copy pi data

View source: R/copy_pi_data.R

copy_pi_dataR Documentation

Copy pi data

Description

Copy the data from each pi into a separate directory and, optionally, delete the data from the pi

Usage

copy_pi_data(
  source,
  dest0 = ".",
  dest1 = as.character(Sys.Date()),
  dest2,
  delete = FALSE
)

Arguments

source

path to where the files are

dest0

path where to move the files to

dest1

name of second level of destination path, defaults to the date

dest2

name of third level of destination path, defaults to an incrementing integer

delete

logical to delete source files

Details

Shutdown the pi, then carefully remove its memory card and put into a card reader. copy_pi_data() can copy data from the memory card. If you don't know the path (including drive name) leave the source argument empty, and file.choose() will help you find it and print this information so you can use it next time. You need to specify where the files will be copied to with dest0. Within this destination directory, copy_pi_data() will make a new directory for each date (remember to copy the files before midnight!) (you can override this by supplying your own name to dest1). Data for each pi are copied into a separate sub-folder which are numbered incrementally by default.

Examples


# make some files
library(fs)
s <- file.path(tempdir(), "source")
dir_create(s)
fs::file_create(path = file.path(s, paste0(letters[1:3], ".csv")))
dir(path = s)

# make destination
d <-  file.path(tempdir(), "dest")
dir_create(d)

# use copy_pi_data() to move them to a new directory
copy_pi_data(source = s, dest0 = d)

dir_tree(d)

# copy again. This time delete the source files
copy_pi_data(source = s, dest0 = d, delete = TRUE)

dir_tree(d)
dir_ls(s) # empty

# clean up
dir_delete(s)
dir_delete(d)


audhalbritter/PFTCFunctions documentation built on Jan. 26, 2024, 5:31 p.m.