Skip to contents

Iterates over a set of DuckDB database files, one per tax year, and extracts all tables defined in the IRS 990 efile schema. The function builds both header tables T00 and data tables T01 to T99 for each year, saving them into the database as flat relational tables.

Usage

extract_csv_tables(
  wd,
  years,
  table_names = NULL,
  ccf = NULL,
  table_headers = NULL
)

Arguments

wd

Character. Base working directory containing yearly subfolders with DuckDB databases.

years

Integer vector. Tax years to process (e.g., 2009:2024).

table_names

Character vector of IRS 990 table names (defaults to get_table_names() if not supplied).

ccf

Data frame. Concordance crosswalk used for variable alignment.

table_headers

Data frame. Output of get_table_headers(), providing schema details for relational table construction.

Value

Invisibly returns NULL. Side effects: writes CSV tables for each year.

Details

The working directory (wd) should contain subdirectories named for each tax year, and each of those subdirectories must include a DuckDB file such as "EFILE2024.duckdb". The function calls helper functions like build_table() and build_rdb_table() to populate these databases.

Examples

if (FALSE) { # \dontrun{
extract_csv_tables(
  wd = "C:/Users/jdlec/DATA/DUCKDB_2025",
  years = 2009:2024
)
} # }