You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
922B

  1. out_addresses <- function(path_addresses_db, path_out_addresses) {
  2. if (is.null(.globals$con_address)) {
  3. withr::defer({
  4. DBI::dbDisconnect(.globals$con_address)
  5. .globals$con_address <- NULL
  6. })
  7. }
  8. addresses <-
  9. prep_open_address_db(path_addresses_db) |>
  10. # keep only the addresses that resolved, others aren't useful in output
  11. dplyr::filter(match_indicator == "Match") |>
  12. # id column is an artifact of the lookup, the key is "address"
  13. dplyr::select(-id) |>
  14. dplyr::rename(
  15. address_lookup = address,
  16. address_resolved = matched_address
  17. ) |>
  18. dplyr::relocate(address_resolved, .after = address_lookup) |>
  19. dplyr::collect() |>
  20. dplyr::mutate(dplyr::across(c(dplyr::starts_with("match_"), tiger_side), factor))
  21. fs::dir_create(fs::path_dir(path_out_addresses))
  22. arrow::write_parquet(addresses, path_out_addresses, version = "2.6")
  23. path_out_addresses
  24. }