I have been trying to figure out this error on python using PubChemPy but I'm stuck. I am trying to input a list of chemicals and gen the Canonical Smiles information for a list of about 200 chemicals. This is the code I am using
for i in List_of_Chemicals['Chemical name']:
prop = pcp.get_properties(['CanonicalSMILES'])
any help would be appreciated
2nd edit: This code goes from a list of names to getting the cid and then the property:
import pubchempy as pcp
# list of chemical names
List_of_Chemicals = ['benzene', 'toluene', '2-nonenal']
for chemical_name in List_of_Chemicals:
cid=pcp.get_cids(chemical_name)
prop = pcp.get_properties('CanonicalSMILES', cid)
print (chemical_name + ' ' + str(prop))
get_properties needs cid as a required argument. You cannot pass in chemical names. So you need an intermediate step to get a list of identifiers corresponding to the names with pcp.get_cids, which I've done in the code above.