Unhelpful traceback
John Nagle
nagle at animats.com
Thu Mar 7 16:23:13 EST 2013
On 3/7/2013 5:10 AM, Dave Angel wrote:
> On 03/07/2013 01:33 AM, John Nagle wrote:
>>
>> "infdraw" is a stream from the zip module, create like this:
>>
>> with inzip.open(zipelt.filename,"r") as infd :
>
> You probably need a 'rb' rather than 'r', since the file is not ASCII.
>
>> self.dofilecsv(infile, infd)
>>
>> This works for data records that are pure ASCII, but as soon as some
>> non-ASCII character comes through, it fails.
No, the ZIP module gives you back the bytes you
put in. "rb" is not accepted there:
File "InfoCompaniesHouse.py", line 197, in dofilezip
with inzip.open(zipelt.filename,"rb") as infd : # do this
file
File "C:\python27\lib\zipfile.py", line 872, in open
raise RuntimeError, 'open() requires mode "r", "U", or "rU"'
RuntimeError: open() requires mode "r", "U", or "rU"
"b" for files is about end of line handling (CR LF -> LF), anyway.
John Nagle
More information about the Python-list
mailing list