Got the basics for matching and importing icd->GBD data
parent
d1edac3c4f
commit
5600ad932d
@ -1 +1 @@
|
||||
{"resources":{"development_sql/ASSOICATING NCTIDs to NDCs and Marketing dates.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-186c896a347-2a3d946d2dea4df7","default-catalog":"aact_db"}}}
|
||||
{"resources":{"Scripts/DiseaseBurdens_create_table.sql":{"default-datasource":"postgres-jdbc-186c896a347-2a3d946d2dea4df7","default-catalog":"aact_db","default-schema":"public"},"Scripts/GlobalBurdensOfDisease2019Codebook.sql":{"default-datasource":"postgres-jdbc-186c896a347-2a3d946d2dea4df7","default-catalog":"aact_db","default-schema":"DiseaseBurden"},"development_sql/ASSOICATING NCTIDs to NDCs and Marketing dates.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-186c896a347-2a3d946d2dea4df7","default-catalog":"aact_db"}}}
|
||||
@ -0,0 +1,32 @@
|
||||
from drugtools.env_setup import ENV,postgres_conn
|
||||
from psycopg2 import extras
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
FILES=[
|
||||
"../non-db_data_sources/GBD and ICD-10_(2019 version)/NONFATAL_cause2code.psv",
|
||||
"../non-db_data_sources/GBD and ICD-10_(2019 version)/COD_cause2code.psv"
|
||||
]
|
||||
SEP="|"
|
||||
|
||||
sql = """
|
||||
INSERT INTO "DiseaseBurden".icd10_to_cause
|
||||
(code,cause_text)
|
||||
VALUES
|
||||
(%(code)s,%(cause)s)
|
||||
"""
|
||||
|
||||
|
||||
#read in files
|
||||
#adjust codes?
|
||||
#load files to table
|
||||
|
||||
with postgres_conn() as pconn, pconn.cursor(cursor_factory=extras.DictCursor) as pcurse:
|
||||
for fpath in FILES:
|
||||
with open(fpath,"r") as fh:
|
||||
for line in fh.readlines():
|
||||
code,cause = line.split(SEP)
|
||||
code = code.strip()
|
||||
cause = cause.strip()
|
||||
|
||||
pcurse.execute(sql,{"code":code,"cause":cause})
|
||||
Loading…
Reference in New Issue