[India_RBI_State_Statistics] Modified download script and handle deletions - #2201
[India_RBI_State_Statistics] Modified download script and handle deletions#2201Krishnam24maheshwari wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the RBI state statistics import pipeline by refactoring the preprocessing script to write to a temporary directory, adding unit tests, updating place mappings, and introducing a validation configuration. The reviewer feedback highlights several issues: df.map incorrectly converts NaN values to 'nan' strings; mapping combined regions like 'Haryana, Delhi & Chandigarh' to Haryana's ID (Q1174) is incorrect; the Wikidata ID for NCT of Delhi should be updated to Q9357528 for AA1 level data; and using a broad wildcard pattern for node_mcf in manifest.json is inefficient and should be scoped to specific directories.
Krishnam24maheshwari
left a comment
There was a problem hiding this comment.
done
In this PR we fixed import execution failures and data corruption issues in the India_RBI_State_Statistics import pipeline
The import was failing at step 1 in rbi_download.py and had several downstream issues preventing successful transformation:
applymapcalls caused runtime errors across different Pandas versions.--input_data=$SCRIPT_PATH/input_files/agriculture/*.xlsxwas unquoted, causing Bash to expand the 42 matched files as positional arguments. As a result, Python only processed the first file, silently dropping the other 41 files (and 7 of 8 files inprice_and_wages).replace('*', '')) caused "Kolkata" and "Chennai" to miss the cache entries in rbi_places_resolver.csv (Kolkata**,Chennai**).Changes made :
rbi_download.py & configs.json :
Migrated table configuration to a local, version-controlled
configs.jsonby default, with automatic fallback if remote GCS paths are unreachable.Added browser headers (
User-Agent,Accept,Accept-Language) to prevent HTTP 403 rejections.Added caching to skip already downloaded files (
input_files/).Isolated individual table downloads in
try/exceptblocks so a single transient failure does not abort the entire batch.run.sh
Quoted Input Globs: Enclosed
--input_data="$SCRIPT_PATH/input_files/agriculture/*.xlsx"and--input_data="$SCRIPT_PATH/input_files/price_and_wages/*.xlsx"in quotes sostat_var_processor.pycorrectly expands and processes all 42 agriculture and 8 price/wage tables.Counter Tracking: Added
COUNTERS_PATH=$SCRIPT_PATH/countersand appended--output_countersto all 18 processing commands.Fixed Log Messages: Corrected copy-paste errors in error exit messages.
Added threshold rule for
DELETED_RECORDS_PERCENTto 7. As there are up to 6.9% deletion is happening in one of the file I have added all the deletions findings and reasoning in the doc - https://docs.google.com/document/d/1BLArT3T2-2EVql0Ol8tSYw9QtjFjzCzockJBquMC4AY/edit?tab=t.0