text_plain_output_1.png
import os

import pandas as pd

import pybel

file_dir = '../input/champs-scalar-coupling/structures/'
mols_files = os.listdir(file_dir)
mols_index = dict(map(reversed, enumerate(mols_files)))
mol_name = list(mols_index.keys())

def xyz_to_smiles(fname: str) -> str:
    mol = next(pybel.readfile('xyz', fname))
    smi = mol.write(format='smi')
    return smi.split()[0].strip()

smiles = [xyz_to_smiles(file_dir + i) for i in tqdm(mol_name)]

df_smiles = pd.DataFrame({'molecule_name': mol_name, 'smiles': smiles})
df_smiles.head(11)