Extract All IRS 990 Tables from DuckDB Databases
extract_csv_tables.RdIterates 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.
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.
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.