[Zope] Re: Parsing a file through a Python script

Pierre Godefroy pierre.godefroy at noos.fr
Sun Nov 30 10:25:37 EST 2003


Thanks, but it does not work as it says I am unauthorized in this 
context (valid only only in an external script).

However I uploaded the file through a form and had no problem 
(readlines() passed through without any warning) :

file = REQUEST.form['file_attachment']
for line in file.readlines():
....

Which is kind of strange.

The issue is, I would like to work on a very big file and there may be 
problems with this. I would like to to access the file as it is already 
stored in the ZODB.

Any other idea?

Pierre Godefroy


Bories v. dem Bussche wrote:

> Pierre Godefroy wrote:
>
>> I am trying to parse a file with a Python script (the file is stored 
>> in the same folder as the script) :
>> "marco" is the id of the file :
>>
>> data=str(container.marco)
>> i=0
>> for line in data.readlines():
>> .....
>>
> You might want to try something like
>
> from StringIO import StringIO
> data = StringIO(str(getattr(container,'marco').data))
>
>
> Bories
>





More information about the Zope mailing list