This project turns the original ENA_2023.zip delivery into a reproducible local data workspace:
inputs/: immutable original files, ZIP contents, and extracted module foldersscripts/: Python pipeline scriptsoutputs/: SQLite database plus derived CSV outputsreports/: inventories and profiling reportsnotebooks/: exploratory and derivation notebooks built on top of the SQLite database
The raw source files must exist in the project root:
ENA_2023.zipDICCIONARIO DE DATOS ENA_2023.pdf
Script 01_extract_ena_2023.py also copies both files into inputs/original/ so the project keeps an internal record of the raw inputs used.
Clone the public repository:
git clone https://github.com/AAVADI/ENA2023.git
cd ENA2023Then place the raw source files in the project root:
ENA_2023.zipDICCIONARIO DE DATOS ENA_2023.pdf
Run the full scripted pipeline:
powershell -ExecutionPolicy Bypass -File scripts/run_pipeline.ps1Or run the steps manually:
python scripts/01_extract_ena_2023.py
python scripts/02_load_csvs_to_sqlite.py
python scripts/03_build_summaries.pyFinally, open and run notebooks/2_ena_2023_sqlite_explorer.ipynb if you also want the crop-only LCI outputs in outputs/.
The extraction and processing flow is:
scripts/01_extract_ena_2023.pyscripts/02_load_csvs_to_sqlite.pyscripts/03_build_summaries.pynotebooks/2_ena_2023_sqlite_explorer.ipynbfor crop-only LCI derivations
python scripts/01_extract_ena_2023.pyWhat it does:
- reads
ENA_2023.zipfrom the project root - extracts the ZIP into
inputs/zip_contents/ENA_2023/ - finds every nested
*.rarmodule inside that extracted ZIP - extracts each module into
inputs/extracted_modules/<module_name>/ - copies the raw ZIP and dictionary PDF into
inputs/original/ - writes an inventory to
reports/01_file_inventory.csv
Important note:
- this step requires
bsdtarto be available either onPATHor in one of the locations checked by the script
python scripts/02_load_csvs_to_sqlite.pyWhat it does:
- scans
inputs/extracted_modules/recursively for all CSV files produced by step 1 - loads each CSV into
outputs/01_ena_2023.sqlite - creates one SQLite table per CSV, using sanitized names of the form
<module>__<csv_name> - writes structural metadata to
outputs/02_table_row_counts.csv,outputs/02_table_columns.csv,reports/02_table_catalog.csv, andreports/02_sqlite_overview.json
python scripts/03_build_summaries.pyWhat it does:
- opens
outputs/01_ena_2023.sqlite - inspects all tables
- builds region-level summaries for any table containing a
REGIONcolumn - exports
outputs/03_summary_by_region.csv,outputs/03_region_totals.csv, andoutputs/03_data_overview.json
The same three steps can be run with:
powershell -ExecutionPolicy Bypass -File scripts/run_pipeline.ps1outputs/01_ena_2023.sqlite: consolidated database of all extracted ENA CSV tablesoutputs/02_table_row_counts.csv: row counts and source CSV paths per tableoutputs/02_table_columns.csv: column inventory and sample values per tableoutputs/03_summary_by_region.csv: per-table grouped summaries byREGIONoutputs/03_region_totals.csv: total rows by region across all summarized tablesoutputs/03_data_overview.json: high-level overview of the SQLite contents
This notebook is not part of the raw extraction/loading pipeline. It is a downstream analysis notebook that starts from outputs/01_ena_2023.sqlite and produces crop-only LCI-style outputs.
It:
- reads the SQLite database created by script
02_load_csvs_to_sqlite.py - builds a crop-only name list from crop-related ENA modules
- creates a core crop-geography-area-yield table
- normalizes production inputs into a long LCI-style input table
- merges crop and input data into a final crop-only LCI table
- derives wide crop-by-region files and per-hectare monetary indicators
- estimates some 2023 representative prices and converts selected inputs into
kg/ha,m3/ha, or fuelL/ha
Run scripts 01, 02, and 03 first so outputs/01_ena_2023.sqlite already exists.
Then open and run:
notebooks/2_ena_2023_sqlite_explorer.ipynb
Important note:
- the notebook sets
PROJECT_ROOT = Path.cwd().resolve().parent, so it expects to be launched with the working directory insidenotebooks/
The notebook writes these derived files to outputs/:
04_crop_names_only.csv04_lci_core_crop_geo_yield_area.csv04_lci_inputs_normalized.csv04_lci_table_crop_only.csv04_lci_table_crop_only_part01.csvand following chunk files as needed04_lci_summary_crop_region.csv05_lci_crop_region_inputs_wide.csv05_lci_crop_region_inputs_wide_per_ha.csv05_input_prices_pen_per_kg_2023.csv05_input_prices_assumed_2023_other_units.csv06_lci_crop_region_inputs_kg_ha.csv
- Raw source ZIP:
ENA_2023.zip - Raw source dictionary:
DICCIONARIO DE DATOS ENA_2023.pdf - Source record:
reports/00_sources.md