Created
February 12, 2024 14:56
-
-
Save PietrH/c2c5be775a54da21e8b09c947b279fb5 to your computer and use it in GitHub Desktop.
frictionless datapackage.json to tibble (or csv)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datapackage_json <- | |
jsonlite::read_json("https://raw.githubusercontent.com/inbo/etn/main/inst/assets/datapackage.json") | |
datapackage_tbl <- | |
datapackage_json |> | |
purrr::chuck("resources") |> | |
purrr::map( | |
\(resource) purrr::set_names( | |
purrr::chuck(resource, "schema", "fields"), | |
purrr::chuck(resource, "name") | |
) | |
) |> | |
purrr::map( | |
\(resource) purrr::map( | |
resource, | |
~ dplyr::tibble( | |
name = purrr::pluck(.x, "name"), | |
type = purrr::pluck(.x, "type"), | |
resource_name = unique(names(resource)) | |
) | |
) | |
) |> | |
purrr::map(purrr::list_rbind) |> | |
purrr::list_rbind() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used for inbo/etn#290