igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Re: Loading from a string or file IO object in Python


From: Gábor Csárdi
Subject: Re: [igraph] Re: Loading from a string or file IO object in Python
Date: Thu, 5 Feb 2009 09:31:19 +0100

Chris,

this is of course, Tamas' area, but I have a couple of questions.

1. Is 'PyString_AsString' portable? (Why isn't it called
PyString_AsFile I wonder....) Because some libc versions don't have
fmemopen(), which is the straightforward implementation of handling
strings as files. But maybe the Python people worked around that
somehow, by using temporary files, or I don't know how.

2. I think the cString would not work, because the igraph functions
expect a FILE* and they want to call 'fread' (fscanf, etc.) on it.

Otherwise it is a good idea, the R read/write functions work this way
to read files from anwhere (string, http, etc.), but on windows (and
anything that does not have fmemopen() and open_memstream()) I needed
to use temporary files.

Thanks,
G.

On Thu, Feb 5, 2009 at 2:09 AM, Chris Wj <address@hidden> wrote:
> Alright, I got it to work with cStringIO too now. Didn't take too much
> effort.
>
> On Wed, Feb 4, 2009 at 7:37 PM, Chris Wj <address@hidden> wrote:
>>
>> After reading through the igraph source I found that this was not
>> supported (as far as I could tell). I whipped up a python extension module
>> example that shows how we can distinguish between a string and file object
>> and act accordingly. I attached the example to this e-mail. Although, it
>> does not work for StringIO/cStringIO yet, so hopefully we can work on that.
>> I'll probably add some of these changes to my local branch along with a
>> method that takes in the file contents (GraphML first) straight through a
>> string already loaded in memory.
>>
>> -Chris
>>
>> On Wed, Feb 4, 2009 at 4:41 PM, Chris Wj <address@hidden> wrote:
>>>
>>> Is there a way to read/load from a file object (file io or string io) or
>>> even from a string? Is the only current option to pass in a filename and
>>> have igraph read the file from disk?
>>>
>>> -Chris
>>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

[Prev in Thread] Current Thread [Next in Thread]