Learn R Programming

rcdf (version 0.1.2)

read_rcdf: Read and decrypt RCDF data

Description

This function reads an RCDF file, decrypts its contents using the specified decryption key, and loads it into R as an RCDF object.

Usage

read_rcdf(
  path,
  decryption_key,
  ...,
  password = NULL,
  metadata = list(),
  ignore_duplicates = TRUE,
  recursive = FALSE,
  return_meta = FALSE
)

Value

An RCDF object, which is a list of Parquet files (one for each record) along with attached metadata.

Arguments

path

A string specifying the path to the RCDF archive (zip file). If a directory is provided, all .rcdf files within that directory will be processed.

decryption_key

The key used to decrypt the RCDF contents. This can be an RSA or AES key, depending on how the RCDF was encrypted.

...

Additional parameters passed to other functions, if needed.

password

A password used for RSA decryption (optional).

metadata

An optional list of metadata object containing data dictionaries, value sets, and primary key constraints for data integrity measure (a data.frame or tibble that includes at least two columns: file and pk_field_name. This metadata is applied to the data if provided.

ignore_duplicates

A logical flag. If TRUE, a warning is issued when duplicates are found, based on the primary key/s defined during creation of RCDF file. If FALSE, the function stops with an error.

recursive

Logical. If TRUE and path is a directory, the function will search recursively for .rcdf files.

return_meta

Logical. If TRUE, the metadata will be returned as an attribute of the RCDF object.

Examples

Run this code
dir <- system.file("extdata", package = "rcdf")
rcdf_path <- file.path(dir, 'mtcars.rcdf')
private_key <- file.path(dir, 'sample-private-key.pem')

rcdf_data <- read_rcdf(path = rcdf_path, decryption_key = private_key)
rcdf_data

# Using encrypted/password protected private key
rcdf_path_pw <- file.path(dir, 'mtcars-pw.rcdf')
private_key_pw <- file.path(dir, 'sample-private-key-pw.pem')
pw <- '1234'

rcdf_data_with_pw <- read_rcdf(
  path = rcdf_path_pw,
  decryption_key = private_key_pw,
  password = pw
)

rcdf_data_with_pw

Run the code above in your browser using DataLab