Reputation: 60811
i read a csv into a variable called b
now i am going through every row in it like this:
for row in b:
this dictionary gives me the positions of where these drugs are in the row
:
generic_drugs_mapping={'MORPHINE':[86],
'OXYCODONE':[87],
'OXYMORPHONE':[99],
'METHADONE':[82],
'BUPRENORPHINE':[28],
'HYDROMORPHONE':[54],
'CODEINE':[37],
'HYDROCODONE':[55]}
i am setting drug = 'MORPHINE'
am i able to do this:
row[generic_drugs_mapping[drug][0]]!=''
to check whether there is a value in the row[86]!=''
??
Upvotes: 0
Views: 224
Reputation: 284927
Yes, that should work, assuming those are 0-based indexes into row
. Is there a reason the elements of the dictionary are lists?
Upvotes: 1