1

Can you please tell me if it is possible to get the name of an element in PubChemPy? I found in the documentation that can find the PubChem CID by name:

result = pcp.get_compounds('Glucose', 'name')
print(result)

[Compound(5793)]

But I need the other way around, by CID to find the name of the element. Maybe someone knows how to do this?

Kate
  • 133
  • 7

1 Answers1

2

You can get the Compound with CID as follows:

c = pcp.Compound.from_cid(5090)

then you can get all the information you need from this object. for example:

>>> print c.iupac_name
3-(4-methylsulfonylphenyl)-4-phenyl-2H-furan-5-one

Check the docs for more info on the object attrs

Seif Mahdy
  • 146
  • 8
  • Thanks for the answer, but this is not exactly what I wanted to get. I need to get the title like in **[here](https://pubchem.ncbi.nlm.nih.gov)**. That is, cid=5090 is "Rofecoxib", as **[here](https://pubchem.ncbi.nlm.nih.gov/compound/5090)**. Probably with the help of PubChemPy I will not be able to get what I want. – Kate Jul 28 '22 at 19:26