Skip to content

Commit

Permalink
Add 2023 tax bills (#41)
Browse files Browse the repository at this point in the history
* add 2023 tax bills

* lint

* styler?

* attempt 2 to style

* add rpm tif

* update data

* Revert "update data"

This reverts commit d0e31ea.

* fixing tax bill summary / adding input procedure

Capture manual reviewed fields from tax bills via terminal entry
  • Loading branch information
erhla authored Aug 5, 2024
1 parent 09b98ae commit b313541
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 7 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 6 additions & 2 deletions data-raw/sample_tax_bills/sample_tax_bills_detail.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ row_to_names <- function(df) {

# Different tax bills can have different table sizes depending on the number of
# taxing district.

extract_tax_bill <- function(file) {
base_file <- basename(file)
tbl <- pdf_text(file)[[1]] %>%
tbl <- pdf_text(file) %>%
paste(., collapse = "\n") %>%
str_extract(., regex("MISCELLANEOUS TAXES.*", dotall = TRUE)) %>%
str_split(., "\n") %>%
unlist() %>%
Expand Down Expand Up @@ -61,7 +63,8 @@ extract_tax_bill <- function(file) {
agency_name,
paste0(
"TAXES|Assess|Property|EAV|Local Tax|",
"Total Tax|Do not|Equalizer|cookcountyclerk.com"
"Total Tax|Do not|Equalizer|cookcountyclerk.com|",
"Pursuant|meaning of|If paying later|\\d{15}+|By \\d{2}/"
)
)
)
Expand All @@ -76,6 +79,7 @@ extract_tax_bill <- function(file) {
return(out)
}


# Collect all scanned tables + meta data in a data frame
bills <- map(list_pdf_inputs, extract_tax_bill)
bills_df <- bind_rows(bills)
Expand Down
4 changes: 2 additions & 2 deletions data-raw/sample_tax_bills/sample_tax_bills_detail.csv
Git LFS file not shown
69 changes: 68 additions & 1 deletion data-raw/sample_tax_bills/sample_tax_bills_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,76 @@ library(stringr)
library(readr)
library(data.table)

# add pins/year/class after updating detail
key_cols <- readr::read_csv(
"data-raw/sample_tax_bills/sample_tax_bills_detail.csv"
) %>%
distinct(year, pin, class) %>%
mutate(class = as.character(class)) %>%
filter(year == max(year))

# new data
new_data <- tibble()
for (i in seq_len(key_cols)) {
print(i)
# open file
cur_row <- key_cols[i, ]
cur_file <- str_glue("{cur_row$year}_{cur_row$class}_{cur_row$pin}.pdf")
system(str_glue(
"open data-raw/sample_tax_bills/{cur_file}"
))
print(cur_row)
if (interactive()) {
g1 <- readline("input tax_code, township_name, in_tif, in_ssa: ")
g2 <- readline("input exe_homeowner, exe_senior, exe_freeze,
exe_longtime_homeowner, exe_disabled,
exe_vet_returning, exe_vet_disabled: ")
g3 <- readline("input eav, tax_amt_pre_exe, tax_amt_post_exe: ")
}
g1 <- unlist(str_split(g1, ", "))
g2 <- unlist(str_split(g2, ", "))
g3 <- unlist(str_split(g3, ", "))
final_row <- tibble(
"year" = cur_row$year,
"pin" = cur_row$pin,
"tax_code" = g1[1],
"class" = cur_row$class,
"township_name" = g1[2],
"in_tif" = g1[3],
"in_ssa" = g1[4],
"exe_homeowner" = g2[1],
"exe_senior" = g2[2],
"exe_freeze" = g2[3],
"exe_longtime_homeowner" = g2[4],
"exe_disabled" = g2[5],
"exe_vet_returning" = g2[6],
"exe_vet_disabled" = g2[7],
"eav" = g3[1],
"tax_amt_pre_exe" = g3[2],
"tax_amt_post_exe" = g3[3]
)
new_data <- bind_rows(new_data, final_row)
}

# save updates
new_data <- new_data %>% mutate(across(
matches("in_|exe_"),
~ if_else(.x == "TRUE", TRUE, FALSE)
))
sum_path <- "data-raw/sample_tax_bills/sample_tax_bills_summary.csv"
data <- read_csv(sum_path,
col_types = cols(
pin = "c", tax_code = "c", class = "c",
eav = "c", tax_amt_pre_exe = "c",
tax_amt_post_exe = "c"
)
) %>% bind_rows(new_data)

data %>% write_csv(sum_path)

# Load sample tax bills summary data from file
sample_tax_bills_summary <- readr::read_csv(
"data-raw/sample_tax_bills/sample_tax_bills_summary.csv",
sum_path,
col_types = cols(pin = "c", tax_code = "c", class = "c")
) %>%
mutate(
Expand Down
4 changes: 2 additions & 2 deletions data-raw/sample_tax_bills/sample_tax_bills_summary.csv
Git LFS file not shown
Binary file modified data/sample_tax_bills_detail.rda
Binary file not shown.
Binary file modified data/sample_tax_bills_summary.rda
Binary file not shown.

0 comments on commit b313541

Please sign in to comment.