From a2d962abd8922c63c706ef44e5030a38952fb794 Mon Sep 17 00:00:00 2001 From: Rob Wiederstein Date: Mon, 9 Mar 2026 15:06:54 -0400 Subject: [PATCH] Clean mailing label CSV: blank owner_2, trim label, add city/state/zip --- app.R | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app.R b/app.R index 3a7e9ce..13f09f1 100644 --- a/app.R +++ b/app.R @@ -424,23 +424,31 @@ server <- function(input, output) { ) ) }) + prep_mailing <- function(data) { + data |> + sf::st_drop_geometry() |> + dplyr::select(owner_1, owner_2, label) |> + dplyr::mutate( + owner_2 = dplyr::na_if(owner_2, "NA"), + owner_2 = ifelse(is.na(owner_2), "", owner_2), + label = stringr::str_squish(label), + city = "Venice", + state = "FL", + zip = "34285" + ) + } + output$download_filtered <- downloadHandler( filename = "st_andrews_owners_filtered.csv", content = function(file) { - filteredOwners() |> - sf::st_drop_geometry() |> - dplyr::select(owner_1, owner_2, label) |> - write.csv(file, row.names = FALSE) + write.csv(prep_mailing(filteredOwners()), file, row.names = FALSE) } ) output$download_all <- downloadHandler( filename = "st_andrews_owners_all.csv", content = function(file) { - owners |> - sf::st_drop_geometry() |> - dplyr::select(owner_1, owner_2, label) |> - write.csv(file, row.names = FALSE) + write.csv(prep_mailing(owners), file, row.names = FALSE) } )