[Zope] How to import files via FTP and set attributes.
Thomas B. Passin
tpassin@mitretek.org
Mon, 6 May 2002 11:14:38 -0400
[[Gary Speer]
>
> I am stuck at looping on and parsing the content of the contents.txt
> file to get and pass the attributes to the add object method. I figure
> the solution is best executed with Python in the context of Zope, but I'm
> stuck at figuring out the syntax for this namespace.
> 1) syntax to loop on the content of a file, one line at a time.
I see that Dieter responded to your other questions, so I'll just answer
this one. If you have an open file-like object named File, in Python you
could say:
line =File.readline()
while line:
#do something with the line
line=File.readline()
Or you could read the file into a list all at once:
lines=File.readlines()
for line in lines:
# do something with the line
Remember, line will include any trailing newline character.
Cheers,
Tom P