Hello,
I am trying to edit a large amount of mol files. It happens that the mol files 
are not readable. These broken files should simply be skipped and the program 
should continue to run.
With a try / except this does not seem to be solvable in the rdkit:

from rdkit import Chem
filename = 'C:\\Strukturen\\ProblemMOLs\\99.mol'

try:
    mol = Chem.MolFromMolFile(filename)
except:
    mol = 'Problem File'

print(mol)

A nonsense MOL file shows a (correct) error message on the console and the 
program is interrupted. Here for example:" [16:06:52]None Cannot convert 'jus' 
to unsigned int on line 4".
I don't want an error message on the console but that the program runs into the 
except block. I am grateful for any tip.

Thanks, Ruediger Lang

99.mol:
This is not a mol-file
this is not a mol-file
I am not a mol-file
just something
with numbers
8879 96874 65-sdf


_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to