Reads ZTRAX flat files in chunks, filters data, and loads into SQL database.
Refer to ztrax_layout
read_ztrax(data_dir, states, ZType = c("ZTrans", "ZAsmt"), TableName, KeepColumns = NULL, FilterColumns = NULL, .filter = NULL, chunk_size = 10000)
data_dir | A path to a single directory containing uncompressed folders |
---|---|
states | The name, 2-letter abbreviation, or FIPS code for one or more states. |
ZType | Either |
TableName | Name of table to be added to the database, as it appears in
documentation and raw data file names ( |
KeepColumns | A vector of names of columns to be included in table on
the database, as they appear in documentation ( |
FilterColumns | A vector of names of any columns not already included in
|
.filter | A function, formula to be passed to |
chunk_size | The number of rows to include in each chunk. |
library(dplyr) read_ztrax( data_dir = ztrax_example_dir(), states = c("FL", "NY"), ZType = "ZAsmt", TableName = "TaxExemption", KeepColumns = c("RowID", "TaxExemptionStndCode"), FilterColumns = "FIPS", .filter = ~ filter(., FIPS %in% c("12086", "36005")), chunk_size = 2 )#>#>#> # A tibble: 6 x 2 #> row_id tax_exemption_stnd_code #> <chr> <chr> #> 1 1A284B67-3182-E711-80C2-3863BB43E814 HD #> 2 1E284B67-3182-E711-80C2-3863BB43E814 HD #> 3 1E284B67-3182-E711-80C2-3863BB43E814 SC #> 4 1E284B67-3182-E711-80C2-3863BB43E814 WW #> 5 1D389B67-3182-E711-80C2-3863BB43E813 WW #> 6 1D389B67-3182-E711-80C2-3863BB43E813 HD