GitBucket
Pull requests
Issues
Snippets
Sign in
s18h024
/
Python 分子式抜き出し 改訂版
Fork
0
Created at Tue Jul 20 11:41:55 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 20 Jul 2021
c122b3c
Python 分子式抜き出し 改訂版
import pubchempy as pup import os import time element = [] files =os.listdir("./babel") element_z = [f for f in files if os.path.isfile(os.path.join("./babel", f))] for i in element_z: a=i.replace(".com","") print(a) element.append(a) req = ["MolecularFormula","inchi"] for j in element: out = pup.get_properties(req,j,'name') print(out) try: fname = "./bunshi2/" + j + ".txt" with open(fname,"w") as e: e.write(out[0].get("MolecularFormula")) e.write("\n") e.write(out[0].get("InChI")) time.sleep(1) except: fname = "./bunshi2/" + j + "__error__.txt" with open(fname,"w") as e: e.write("ERROR!\nPlease check your self.") time.sleep(1)