[Tutor] Truncated urlopen

Válas Péter sulinet at postafiok.hu
Mon Feb 11 11:58:48 CET 2013


Hi tutors,

aboard again after a long time.
http://..._export.php?mehet=1 is a link which exports me some data in CSV
correctly when I click on it in my browser. (It contains personal data,
that's why I dotted.) I want to process it directly from Python, excluding
the browser phase.

The following piece of code in Python 3.3 prints the first n-1 lines
nicely, then the beginning of the last line truncated. I mean there are 12
fields in CSV and in the last line only 1.5 fields of them are displayed. I
suspect some closing/caching error.
In the first times it worked well but after a certain time it spoiled
without PHP code being modified. I guess it may somehow be connected to
quantity of lines.
How could I read the last line?
Thx, Péter

from urllib.request import urlopen
x=urlopen('http://..._export.php?mehet=1')
y=x.read().decode('windows-1250')
print(y)

Output looks like this:
159;Name of customer159;xxxx at gmail.com;phone;22;0;0;0;1;0;0;2013-02-09
20:20:26
160;Name of customer160;yyyy at gmail.com;phone;14;0;0;1;0;0;0;2013-02-09
20:38:16
161;Name of c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130211/3719a008/attachment-0001.html>


More information about the Tutor mailing list