Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write CSVs from remotely read package to disk #77

Closed
peterdesmet opened this issue Jan 11, 2022 · 0 comments
Closed

Write CSVs from remotely read package to disk #77

peterdesmet opened this issue Jan 11, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request function:write_package Function write_package()

Comments

@peterdesmet
Copy link
Member

One can read a Data Package (read_package()) from a URL or download it first and then read it locally.

The current behaviour for writing a remotely read package is to not copy the files to disk, since they are already available online. However, that makes it more difficult to 1) download a whole Data Package using R and 2) update a Data Package (e.g. adding a resource), because the originally local paths are now URLs pointing to an online CSV, and that might not be the version you want to point to.

library(frictionless)
package <- read_package("https://zenodo.org/record/5070086/files/datapackage.json")
#> Please make sure you have the right to access data from this Data Package for your intended use.
#> Follow applicable norms or requirements to credit the dataset and its authors.
#> For more information, see https://doi.org/10.5281/zenodo.5070086
# Paths are local
package$resources[[2]]$path
#> [1] "O_WESTERSCHELDE-gps-2018.csv" "O_WESTERSCHELDE-gps-2019.csv"
#> [3] "O_WESTERSCHELDE-gps-2020.csv"
write_package(package, "my_directory")
list.files("my_directory")
#> [1] "datapackage.json"

written_package <- read_package("my_directory/datapackage.json")
#> Please make sure you have the right to access data from this Data Package for your intended use.
#> Follow applicable norms or requirements to credit the dataset and its authors.
#> For more information, see https://doi.org/10.5281/zenodo.5070086
# Paths are URLs now
written_package$resources[[2]]$path
#> [1] "https://zenodo.org/record/5070086/files/O_WESTERSCHELDE-gps-2018.csv"
#> [2] "https://zenodo.org/record/5070086/files/O_WESTERSCHELDE-gps-2019.csv"
#> [3] "https://zenodo.org/record/5070086/files/O_WESTERSCHELDE-gps-2020.csv"

Created on 2022-01-11 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request function:write_package Function write_package()
Projects
None yet
Development

No branches or pull requests

1 participant