GitBucket
Pull requests
Issues
Snippets
Sign in
db2021
/
Python 分子式抜き出し
Fork
0
Created at Wed Jun 23 14:49:21 JST 2021
Download ZIP
HTTP
Embed
Embed this snippet in your website.
HTTP
Clone with Git using the repository's web address.
Code
Revision
Forks
s18h024
revised this
on 23 Jun 2021
3118058
Python 分子式抜き出し
import pubchempy as pup import os import time element = [] files =os.listdir("./output") element_z = [f for f in files if os.path.isfile(os.path.join("./output", f))] for i in element_z: a=i.replace(".sdf","") print(a) element.append(a) req = ["MolecularFormula"] for j in element: out = pup.get_properties(req,j,'name') try: fname = "./bunshi/" + j + ".txt" with open(fname,"w") as e: e.write(out[0].get("MolecularFormula")) time.sleep(1) except: fname = "./bunshi/" + j + "__error__.txt" with open(fname,"w") as e: e.write("ERROR!\nPlease check your self.") time.sleep(1)