Title: | 'Palantir Foundry' Software Development Kit |
---|---|
Description: | Interface to 'Palantir Foundry', including reading and writing structured or unstructured datasets, and more <https://www.palantir.com/platforms/foundry/>. |
Authors: | Alexandre Guinaudeau [aut, cre], Palantir Technologies [aut, cph] |
Maintainer: | Alexandre Guinaudeau <[email protected]> |
License: | Apache License 2.0 |
Version: | 0.13.0 |
Built: | 2025-03-01 05:06:49 UTC |
Source: | https://github.com/palantir/palantir-r-sdk |
Download Foundry Files locally.
datasets.download_files(alias, files)
datasets.download_files(alias, files)
alias |
The alias representing the Dataset. |
files |
The file paths or file properties. |
A list mapping Foundry Dataset files to the local file paths where files were downloaded.
## Not run: # Download a single file in a Dataset downloaded_file <- datasets.download_files("my_alias", c("dir/my_file.csv")) read.csv(downloaded_file$`dir/my_file.csv`) # Extract text from all PDF files in a Dataset pdf_files <- datasets.list_files("my_alias", regex = ".*\\.pdf") downloaded_files <- datasets.download_files("my_alias", pdf_files) contents <- lapply(downloaded_files, pdftools::pdf_text) ## End(Not run)
## Not run: # Download a single file in a Dataset downloaded_file <- datasets.download_files("my_alias", c("dir/my_file.csv")) read.csv(downloaded_file$`dir/my_file.csv`) # Extract text from all PDF files in a Dataset pdf_files <- datasets.list_files("my_alias", regex = ".*\\.pdf") downloaded_files <- datasets.download_files("my_alias", pdf_files) contents <- lapply(downloaded_files, pdftools::pdf_text) ## End(Not run)
Lists the files stored in a Foundry Dataset.
datasets.list_files(alias, regex = ".*")
datasets.list_files(alias, regex = ".*")
alias |
The alias representing the Dataset. |
regex |
A regex used to filter files by path. |
The lists of file properties.
## Not run: # List all PDF files in a Dataset all_files <- datasets.list_files("my_dataset", regex=".*\\.pdf") # Get all file names file_names <- sapply(all_files, function(x) x$path) ## End(Not run)
## Not run: # List all PDF files in a Dataset all_files <- datasets.list_files("my_dataset", regex=".*\\.pdf") # Get all file names file_names <- sapply(all_files, function(x) x$path) ## End(Not run)
Reads a tabular Foundry dataset as data.frame or an Apache Arrow Table.
datasets.read_table( alias, columns = NULL, row_limit = NULL, format = "data.frame" )
datasets.read_table( alias, columns = NULL, row_limit = NULL, format = "data.frame" )
alias |
The alias representing the Dataset. The Dataset must be tabular, i.e. have a schema. |
columns |
The subset of columns to retrieve. |
row_limit |
The maximum number of rows to retrieve. |
format |
The output format, can be 'arrow' or 'data.frame'. |
A data.table or an Arrow Table
Note that types may not match exactly the Foundry column types. See https://arrow.apache.org/docs/r/articles/arrow.html for details on type conversions from an arrow Table to a data.frame.
## Not run: # Download a subset of a tabular Dataset df <- datasets.read_table("my_input", columns = c("columnA", "columnB"), row_limit = 1000) ## End(Not run)
## Not run: # Download a subset of a tabular Dataset df <- datasets.read_table("my_input", columns = c("columnA", "columnB"), row_limit = 1000) ## End(Not run)
Upload a local file or folder to a Foundry Dataset.
datasets.upload_files(files, alias)
datasets.upload_files(files, alias)
files |
The local files and folders to upload. If a folder is provided, all files found recursively in subfolders will be uploaded. |
alias |
The alias representing the Dataset. |
A list mapping local file paths to the corresponding Foundry Dataset file.
## Not run: # Upload RDS files to a Dataset local_dir <- file.path(tempdir(), "to_upload") dir.create(local_dir) saveRDS(iris, file.path(local_dir, "iris.rds")) saveRDS(Titanic, file.path(local_dir, "Titanic.rds")) datasets.upload_files(local_dir, "my_output") ## End(Not run)
## Not run: # Upload RDS files to a Dataset local_dir <- file.path(tempdir(), "to_upload") dir.create(local_dir) saveRDS(iris, file.path(local_dir, "iris.rds")) saveRDS(Titanic, file.path(local_dir, "Titanic.rds")) datasets.upload_files(local_dir, "my_output") ## End(Not run)
Writes a data.frame to a Foundry dataset.
datasets.write_table(data, alias)
datasets.write_table(data, alias)
data |
A data.frame or an arrow Table. |
alias |
The alias representing the Dataset. |
Note that types may not be exactly preserved and all types are not supported. See https://arrow.apache.org/docs/r/articles/arrow.html for details on type conversions from a data.frame to an arrow Table. Use arrow::Table$create to use more granular types.
Row names are silently removed.
## Not run: datasets.write_table(mtcars, "my_output") ## End(Not run)
## Not run: datasets.write_table(mtcars, "my_output") ## End(Not run)