Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ This import pipeline processes various socio-economic and agricultural statistic

## Configuration

The `rbi_download.py` script relies on a configuration file named `configs.py` to fetch the URLs, filenames, and categories for the data to be downloaded.
The `rbi_download.py` script relies on a local, version-controlled JSON configuration file named `configs.json` to specify URLs, filenames, and categories for the data to be downloaded.

Sample data of the config file:
URLS_CONFIG=[
Sample structure of `configs.json`:
```json
{
"URLS_CONFIG": [
{
"url": "https://rbidocs.rbi.org.in/rdocs/Publications/DOCs/58T_xxxxxxxxxxxxx.XLSX",
"category": "agriculture",
"filename": "state_wise_pattern_of_land_use_gross_sown_area.xlsx"
},
...
]
"url": "https://rbidocs.rbi.org.in/rdocs/Publications/DOCs/58T_xxxxxxxxxxxxx.XLSX",
"category": "agriculture",
"filename": "state_wise_pattern_of_land_use_gross_sown_area.xlsx"
}
]
}
```

This approach makes the import process semi-automatic: if the download URLs change in future RBI releases (which commonly happens due to shifting table numbers or publication structures), only this configuration file needs to be updated, rather than modifying the Python script itself.
This makes the import process **Semi-Automated**: if download URLs change in future RBI releases (due to updated publication links or revised tables), only `configs.json` needs to be updated without modifying script logic. Additionally, `rbi_download.py` employs connection pooling with `requests.Session()` + `HTTPAdapter(Retry(...))`, validates file magic bytes (`PK\x03\x04`), and atomically writes downloaded files to prevent corrupted/partial files.

## Data Acquisition and Initial Preprocessing

Expand Down Expand Up @@ -288,3 +291,10 @@ python3 stat_var_processor.py \
--existing_statvar_mcf=gs://unresolved_mcf/scripts/statvar/stat_vars.mcf \
--output_path=../../statvar_imports/database_on_indian_economy/india_rbi_state_statistics/output_files/infrastructure/state_wise_road_constructed_under_pmgsy_output
```

## Validation Configuration and Thresholds

This import uses `validation_config.json` with a 7% record deletion threshold (`DELETED_RECORDS_PERCENT: 7`).
- **Rationale & Analysis**: Up to 7% of records may be deleted or modified across historical revisions and cleanups of unmapped sub-divisions and regional reporting structures across RBI state tables.
- **Justification Document**: For detailed root cause analysis, table breakdown, and justification, see the [RBI State Statistics Deletion Threshold Justification Doc](https://docs.google.com/document/d/19k3zyNk_KR9D4dVpXdGvlXKk6AMOzoYU2I1khJSsX8w/edit?resourcekey=0-JR3lDK9eNfo3ftEV6YpGxQ&tab=t.0#heading=h.iiqodx2yoqc8).

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Table 105: STATE-WISE EXPENDITURE ON RELIEF ON NATURAL CALAMITIES,measuredProper
Table 106: STATE-WISE SUSTAINABLE DEVELOPMENT GOALS (SDGs) SCORE,measuredProperty,score,populationType,SustainableDevelopmentGoals,name,"""Sustainable Development Goals Score""",,,,,,,,
State/ Union Territory,observationAbout,{Data},,,,,,,,,,,,
State/Union Territory,observationAbout,{Data},,,,,,,,,,,,
"Haryana, Delhi & Chandigarh",observationAbout,country/IND
1987,observationDate,1987,value,{Number},,,,,,,,,,
1989,observationDate,1989,value,{Number},,,,,,,,,,
1991,observationDate,1991,value,{Number},,,,,,,,,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,83 +15,103 @@
"input_files/agriculture/*.xlsx",
"input_files/environment/*.xlsx",
"input_files/infrastructure/*.xlsx",
"input_files/price_and_wages/*.xlsx"
"input_files/price_and_wages/*.xlsx",
"counters/*.csv"
],
"import_inputs": [
{
"template_mcf": "output_files/agriculture/agriculture_output.tmcf",
"cleaned_csv": "output_files/agriculture/agriculture_output.csv"
"cleaned_csv": "output_files/agriculture/agriculture_output.csv",
"node_mcf": "output_files/agriculture/*.mcf"
},
{
"template_mcf": "output_files/environment/state_wise_expenditure_on_relief_on_natural_calamities_output.tmcf",
"cleaned_csv": "output_files/environment/state_wise_expenditure_on_relief_on_natural_calamities_output.csv"
"cleaned_csv": "output_files/environment/state_wise_expenditure_on_relief_on_natural_calamities_output.csv",
"node_mcf": "output_files/environment/*.mcf"
},
{
"template_mcf": "output_files/environment/state_wise_forest_cover_output.tmcf",
"cleaned_csv": "output_files/environment/state_wise_forest_cover_output.csv"
"cleaned_csv": "output_files/environment/state_wise_forest_cover_output.csv",
"node_mcf": "output_files/environment/*.mcf"
},
{
"template_mcf": "output_files/environment/state_wise_sdg_score_output.tmcf",
"cleaned_csv": "output_files/environment/state_wise_sdg_score_output.csv"
"cleaned_csv": "output_files/environment/state_wise_sdg_score_output.csv",
"node_mcf": "output_files/environment/*.mcf"
},
{
"template_mcf": "output_files/environment/state_wise_tree_cover_output.tmcf",
"cleaned_csv": "output_files/environment/state_wise_tree_cover_output.csv"
"cleaned_csv": "output_files/environment/state_wise_tree_cover_output.csv",
"node_mcf": "output_files/environment/*.mcf"
},
{
"template_mcf": "output_files/environment/sub_division_wise_annual_rainfall_output.tmcf",
"cleaned_csv": "output_files/environment/sub_division_wise_annual_rainfall_output.csv"
"cleaned_csv": "output_files/environment/sub_division_wise_annual_rainfall_output.csv",
"node_mcf": "output_files/environment/*.mcf"
},
{
"template_mcf": "output_files/price_and_wages/price_and_wages_output.tmcf",
"cleaned_csv": "output_files/price_and_wages/price_and_wages_output.csv"
"cleaned_csv": "output_files/price_and_wages/price_and_wages_output.csv",
"node_mcf": "output_files/price_and_wages/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_availability_of_power_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_availability_of_power_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_availability_of_power_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_electricity_transmission_distribution_losses_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_electricity_transmission_distribution_losses_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_electricity_transmission_distribution_losses_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_installed_capacity_of_power_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_installed_capacity_of_power_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_installed_capacity_of_power_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_length_of_national_highways_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_length_of_national_highways_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_length_of_national_highways_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_length_of_roads_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_length_of_roads_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_length_of_roads_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_length_of_state_highways_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_length_of_state_highways_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_length_of_state_highways_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_per_capita_availability_of_power_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_per_capita_availability_of_power_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_per_capita_availability_of_power_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_power_requirement_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_power_requirement_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_power_requirement_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_railway_route_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_railway_route_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_railway_route_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_road_constructed_under_pmgsy_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_road_constructed_under_pmgsy_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_road_constructed_under_pmgsy_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
},
{
"template_mcf": "output_files/infrastructure/state_wise_telephones_per_100_population_output.tmcf",
"cleaned_csv": "output_files/infrastructure/state_wise_telephones_per_100_population_output.csv"
"cleaned_csv": "output_files/infrastructure/state_wise_telephones_per_100_population_output.csv",
"node_mcf": "output_files/infrastructure/*.mcf"
}
],
"cron_schedule": "0 10 * * 1"
"cron_schedule": "0 10 * * 1",
"validation_config_file": "validation_config.json"
}
]
}
Loading