jst_combine_outputs | R Documentation |
jst_combine_outputs()
helps you to manage the multitude of files you might
receive after running jst_import()
or jst_import_zip()
with more than
one batch.
jst_combine_outputs(
path,
write_to_file = TRUE,
out_path = NULL,
overwrite = FALSE,
clean_up = FALSE,
warn = TRUE
)
path |
A path to a directory, containing .csv-files from
|
write_to_file |
Should combined data be written to a file? |
out_path |
A directory where to write the combined files. If no
directory is supplied and |
overwrite |
Should files be overwritten? |
clean_up |
Do you want to remove the original batch files? Use with caution. |
warn |
Should warnings be raised, if the file type cannot be determined? |
Splitting the output of jst_import()
or jst_import_zip()
might be done
for multiple reasons, but in the end you possibly want to combine all outputs
into one file/data.frame. This function makes a few assumptions in order to
combine files:
Files with similar names (except for trailing dashes with numbers) belong together and will be combined into one file.
The names of the combined files can be determined from the original files.
If you want to combine foo-1.csv
and foo-2.csv
, the combined file will
be combined_foo.csv
.
The directory only contains files which were imported via
jst_import()
or jst_import_zip()
. If the directory contains other
.csv
files, you should supply a character vector with paths to only those
files, which you want to import.
Either writes to disk, or returns a list with all combined files.
jst_re_import()
# set up a temporary directory
tmp <- tempdir()
# find multiple files
file_list <- rep(jst_example("article_with_references.xml"), 2)
# convert and write to file
jst_import(file_list, "article", out_path = tmp, .f = jst_get_article,
n_batches = 2, show_progress = FALSE)
# combine outputs
jst_combine_outputs(tmp)
list.files(tmp, "csv")
## Not run:
# Trying to combine the files again raises an error.
jst_combine_outputs(tmp)
## End(Not run)
# this doesn't
jst_combine_outputs(tmp, overwrite = TRUE)
# we can remove the original files too
jst_combine_outputs(tmp, overwrite = TRUE, clean_up = TRUE)
list.files(tmp, "csv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.