Import a data file into the current folder structure

External data should be collected in a traceable way, keeping the information where it came from. The function takes the file specified by filename, copies it to a path and creates/updates a logfile with the information @File (filename in the new location), @Source (original filename), @Description (user-defined comment), @Date (date of import) @MD5 File (MD5 sum of imported file), @MD5 Source (MD5 sum of source file), @MD5 Customer (MD5 sum provided by customer/user), and @MD5 Check (Check message).

import_IQRdataOriginal(
  filename,
  description = "No description available",
  MD5 = NULL,
  target = basename(filename),
  interactive = TRUE
)

Arguments

filename

relative or absolute path to the file to be imported.

description

description of the imported file.

MD5

customer-provided MD5 sum. If not provided, this will be noted in the log file.

target

new name, with or without path information, of the imported file (the base name of the original file by default).

interactive

if TRUE, ask the user what should be done in case of conflicts.

Details

The target folder will automatically be created if not existing. A logfile named "datasources.txt" will be created if missing in the target folder.

The source file will always be copied to the target location unless the target file already extisted and had a different MD5 sum than the new file. In that case, the user is asked (in interactive mode), if the file should be overwritten. In non-interactive mode, the file is always overwritten. If a file was copied, the new file is checked against the provided MD5 information and available information in the logfile. The logfile is then updated appropriately:

  • If MD5 sums are not consistent, a warning will be thrown and written to the logfile

  • If the target file was not in the logfile, a new entry is created

  • If the target file was in the logfile, the entry is updated

Author

Daniel Kaschek, IntiQuan

Examples

if (FALSE) { # \dontrun{

# Just for illustration
import_IQRdataOriginal(
  filename    = "../../Communication/Emails/181107/PKdata.xls",
  description = "PK data for compound X provided by Y via Email",
  target      = "data_X_PK.xls"
)

# Import to another folder
import_IQRdataOriginal(
  filename    = "../../Communication/Emails/181107/PKdata.xls",
  description = "PK data for compound X provided by Y via Email",
  target      = "../test/data_X_PK.xls"
)

} # }