# Conversion from a SAS file to a single parquet file :
table_to_parquet(
path_to_file = system.file("examples","iris.sas7bdat", package = "haven"),
path_to_parquet = tempfile(fileext = ".parquet")
)
# Conversion from a SPSS file to a single parquet file :
table_to_parquet(
path_to_file = system.file("examples","iris.sav", package = "haven"),
path_to_parquet = tempfile(fileext = ".parquet"),
)
# Conversion from a Stata file to a single parquet file without progress bar :
table_to_parquet(
path_to_file = system.file("examples","iris.dta", package = "haven"),
path_to_parquet = tempfile(fileext = ".parquet")
)
# Reading SPSS file by chunk (using `max_rows` argument)
# and conversion to multiple parquet files :
table_to_parquet(
path_to_file = system.file("examples","iris.sav", package = "haven"),
path_to_parquet = tempfile(),
max_rows = 50,
)
# Reading SPSS file by chunk (using `max_memory` argument)
# and conversion to multiple parquet files of 5 Kb when loaded (5 Mb / 1024)
# (in real files, you should use bigger value that fit in memory like 3000
# or 4000) :
table_to_parquet(
path_to_file = system.file("examples","iris.sav", package = "haven"),
path_to_parquet = tempfile(),
max_memory = 5 / 1024
)
# Reading SAS file by chunk of 50 lines with encoding
# and conversion to multiple files :
table_to_parquet(
path_to_file = system.file("examples","iris.sas7bdat", package = "haven"),
path_to_parquet = tempfile(),
max_rows = 50,
encoding = "utf-8"
)
# Conversion from a SAS file to a single parquet file and select only
# few columns :
table_to_parquet(
path_to_file = system.file("examples","iris.sas7bdat", package = "haven"),
path_to_parquet = tempfile(fileext = ".parquet"),
columns = c("Species","Petal_Length")
)
# Conversion from a SAS file to a partitioned parquet file :
table_to_parquet(
path_to_file = system.file("examples","iris.sas7bdat", package = "haven"),
path_to_parquet = tempfile(),
partition = "yes",
partitioning = c("Species") # vector use as partition key
)
# Reading SAS file by chunk of 50 lines
# and conversion to multiple files with zstd, compression level 10
if (isTRUE(arrow::arrow_info()$capabilities[['zstd']])) {
table_to_parquet(
path_to_file = system.file("examples","iris.sas7bdat", package = "haven"),
path_to_parquet = tempfile(),
max_rows = 50,
compression = "zstd",
compression_level = 10
)
}
Run the code above in your browser using DataLab