Dear Jean-Paul,
On Thu, Jan 26, 2012 at 4:30 AM, JP <[email protected]> wrote:
>
> Good morning, I know that now we can use GZ file directly in MolSuppliers
> (with the code in trunk), but can we use zipped/compressed files when
> writing too?
One minor clarification before I answer your question: the capability
to deal with GZ files in SDMolSuppliers and SDWriters is also in the
2011_12_1 release.
To answer your question, the following bit of code works:
f = gzip.open('output.sdf.gz','w+')
w = Chem.SDWriter(f)
for m in ms: w.write(m)
w.flush()
f.flush()
w=None
f=None
The bit with being required to call "flush" is ugly and possibly
unnecessary, but it's safe (otherwise there's some risk that the file
won't be complete). This is something that should be improved on the
backend, but in the meantime the above steps should work.
-greg
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss