Skip to contents

This function processes and validates a user-provided control CSV file. The process includes reading the file, preprocessing it to remove empty rows or columns, and then validating and formatting based on the given control type and action. If the file doesn't meet the specific requirements or if any validation rules are violated, appropriate errors or warnings will be raised.

Usage

process_control_csv(
  user_csv,
  user_action,
  control_type,
  file_type = "na",
  bind_data = NULL,
  database = Sys.getenv("SDB_PATH"),
  config_yml = Sys.getenv("SDB_CONFIG")
)

Arguments

user_csv

The path to the user's control CSV file. This will be read into a data frame.

user_action

A character string indicating the action the user is taking (e.g., 'upload').

control_type

A character string specifying the type of controls in the user CSV.

file_type

A character string indicating the type of file (default is "na").

bind_data

A named list of data to be added to the user file. The list names will be the new columns and the values to their respective column. Default is NULL, which means that no data will be binded.

database

A character string indicating the path to the SQLite database used for validation checks. Defaults to the system environment variable 'SDB_PATH'.

config_yml

A character string indicating the path to a configuration YAML file. Defaults to the system environment variable 'SDB_CONFIG'.

Value

A processed and validated control CSV as a data frame.

Examples

if (FALSE) { # \dontrun{
# Provide the path to the user CSV file and action details
user_file_path <- "path/to/user/control_file.csv"
action <- "upload"
type <- "quality_control"

# Process and validate the user CSV
processed_data <- process_control_csv(user_file_path, action, type)
} # }