00krishna-tools / pydhs

python library to manipulate dhs data fro Antonio Ramos
MIT License
0 stars 0 forks source link

There was a change in the names of some of the DHS tables. This causes script 1_prepare.. to crash. #17

Closed 00krishna closed 6 years ago

00krishna commented 6 years ago

Looks like DHS changed some of the names of their files. This causes the prepare script to crash.

The error message looks like:

(pDhs) --- [krishnab@asvalayana][/media/rudra/development/public_health/pydhs/scripts/]‹master* M› » python 1_prepare_database_for_processing.py
/home/krishnab/anaconda3/envs/pDhs/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
Sorry, something went wrong with running the query
Traceback (most recent call last):
  File "1_prepare_database_for_processing.py", line 38, in <module>
    main('db_dhs_global', 'tablelists/tablelist_all.csv')
  File "1_prepare_database_for_processing.py", line 14, in main
    c.action_add_table_name_to_each_database_table(tablefile)
  File "/home/krishnab/anaconda3/envs/pDhs/lib/python3.6/site-packages/pydhs-0.1.0-py3.6.egg/pydhs/Controller.py", line 74, in action_add_table_name_to_each_database_table
    self.db.get_regular_cursor_query_no_return(query, (tbl, AsIs(tbl)))
  File "/home/krishnab/anaconda3/envs/pDhs/lib/python3.6/site-packages/pydhs-0.1.0-py3.6.egg/pydhs/Database.py", line 136, in get_regular_cursor_query_no_return
    self.rcursor.execute(query, strings)
psycopg2.ProgrammingError: relation "bdbr70fl" does not exist
CONTEXT:  SQL statement "alter table bdbr70fl add column tablename varchar default null"
PL/pgSQL function inline_code_block line 7 at SQL statement
00krishna commented 6 years ago

This solution is to make some changes to the tablelist_all.csv and tablelist_br.csv and possibly the wealth tables too. I will note the changes here.

00krishna commented 6 years ago

The list of tables that changed.

bdbr70fl --> bdbr72fl; cibr61fl --> cibr62fl; mwbr4dfl --> mwbr4efl; mvbr51fl --> mvbr52fl; aobr61fl --> aobr62fl; khbr72fl --> khbr73fl; gnbr61fl --> gnbr62fl; zwbr70fl --> zwbr71fl; mdbr41fl --> mdbr42fl;

00krishna commented 6 years ago

All of the new tables have now been added to the tablelist_all.csv and tablelist_br.csv files and the script seems to be running. So closing this issue.