1

I'm using the rdkit Chem library to create an svg file:

Draw.MolToFile(mol, path, size=(400, 400))

It usually works fine when I read it like so:

with open(path) as myfile:
    image = myfile.read()

Other times it will return an empty string unless I add a time.sleep(0.1) before reading it, and then it will work.

Any idea why this could be happening?

System Specifications :

rdkit version: 2019.09.3

OS: ubuntu 18.04.5 LTS

file extension: svg
Vandan Revanur
  • 459
  • 6
  • 17
G Smith
  • 53
  • 1
  • 9
  • MolToFile() has a ton of modes depending on what system you're running on (maybe tell us the OS) and what file type you're saving (tell us the file extension). Without that info it will be much harder to know what's wrong. Also please tell us what version of rdkit you're using (MolToFile was partially rewritten not long ago: https://github.com/rdkit/rdkit/pull/2866) – John Zwinck Sep 12 '20 at 12:23
  • just edited it with that information, thanks – G Smith Sep 12 '20 at 12:31

0 Answers0