Re: [Rdkit-discuss] Export pandas DataFrame to xlsx with molecule images

2014-11-04 Thread Grégori Gerebtzoff
Hi Samo, I don't think you need temporary files at all; have you tried something like this? from cStringIO import StringIO image_file = StringIO() img = Draw.MolToImage(row[molCol], size=size) img.save(image_file, format='PNG') image_data = image_file.getvalue() Grégori On 03. 11. 14 21:44,

Re: [Rdkit-discuss] Export pandas DataFrame to xlsx with molecule images

2014-11-04 Thread Samo Turk
Hi Grégori, I tried exactly what you suggested already yesterday but it didn't work. I did find a solution after some fiddling and now it works. https://github.com/rdkit/rdkit/pull/371/files Thanks! On Tue, Nov 4, 2014 at 9:32 AM, Grégori Gerebtzoff greg...@gerebtzoff.com wrote: Hi Samo,

Re: [Rdkit-discuss] Export pandas DataFrame to xlsx with molecule images

2014-11-03 Thread Samo Turk
Hi Grégori, Thanks for pointing this out. I modified the code and now it writes only one temporary file. Cheers, Samo On Fri, Oct 31, 2014 at 10:56 AM, Grégori Gerebtzoff greg...@gerebtzoff.com wrote: Hi Samo, I used a few years ago the PHPExcel library to put images into an Excel file,

Re: [Rdkit-discuss] Export pandas DataFrame to xlsx with molecule images

2014-10-31 Thread Grégori Gerebtzoff
Hi Samo, I used a few years ago the PHPExcel library to put images into an Excel file, and it was not necessary to use physical files. Having a quick look at the library I found this class (probably the one I used): PHPExcel_Worksheet_MemoryDrawing (source code:

[Rdkit-discuss] Export pandas DataFrame to xlsx with molecule images

2014-10-30 Thread Samo Turk
Hi rdkiters, Due to popular demand I started to work on a function to export pandas DataFrame to xlsx with molecule images embedded. Because of the xlsx specifics the code is not optimal. The most annoying thing about this implementation is that it has to write all images to the hard drive,