Diff of /IQVIA/nctid2label.py [000000] .. [bc9e98]

Switch to unified view

a b/IQVIA/nctid2label.py
1
import csv 
2
3
4
def nctid2label_dict():
5
    nctid2outcome = dict() 
6
    outcome2label = dict() 
7
    nctid2label = dict() 
8
    with open("trialtrove/outcome2label.txt", 'r') as fin: 
9
        lines = fin.readlines() 
10
        for line in lines:
11
            outcome = line.split('\t')[0]
12
            label = line.strip().split('\t')[1]
13
            outcome2label[outcome] = label 
14
15
    with open("trialtrove/trial_outcomes_v1.csv", 'r') as csvfile: 
16
        csvreader = list(csv.reader(csvfile))[1:]
17
        for row in csvreader:
18
            nctid = row[0]
19
            outcome = row[1]
20
            nctid2outcome[nctid] = outcome 
21
22
    for nctid,outcome in nctid2outcome.items():
23
        nctid2label[nctid] = outcome2label[outcome]
24
25
    return nctid2label 
26
27
nctid2label = nctid2label_dict() 
28
print(nctid2label)
29