<br><br><div class="gmail_quote">On Mon, Apr 4, 2011 at 11:22 PM, Chris Barker <span dir="ltr"><<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 4/4/11 9:03 PM, <a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a> wrote:<br>
> On Mon, Apr 4, 2011 at 11:42 PM, Charles R Harris<br>
<br>
</div><div class="im">>>>    File "/sw/lib/python2.4/site-packages/numpy/lib/_datasource.py",<br>
>>> line 477, in open<br>
>>>      return _file_openers[ext](found, mode=mode)<br>
>>> IOError: invalid mode: Ub<br>
>>><br>
>><br>
>> Guess that wasn't tested before ;) I thought that was strange when I saw it.<br>
>> The source of the problem is line 2035 in npyio.py. Additionally, Since<br>
>> genloadtxt needs to have byte strings the 'rb" mode should probably be used.<br>
>> That works on linux, both for python 2 and python 3, but doing that might<br>
>> uncover genfromtxt problems on other platforms.<br>
<br>
> "rb" is fine on Windows with python 3.2, (that's what I tested<br>
> initially for this bug)<br>
<br>
</div>IIUC, "Ub" is undefined -- "U" means universal newlines, which makes no<br>
sense when used with "b" for binary. I looked at the code a ways back,<br>
and I can't remember the resolution order, but there isn't any checking<br>
for incompatible flags.<br>
<br>
I'd expect that genfromtxt, being txt, and line oriented, should use<br>
'rU'. but if it wants the raw line endings (why would it?) then rb<br>
should be fine.<br>
<br>
Note that if you only test with unix (\n) and dos (\r\n) line endings,<br>
it may work with 'b', if it's splitting on '\n', but not if you try it<br>
with Mac endings (\r). Of course with OS-X mac endings are getting<br>
pretty uncommon.<br>
<font color="#888888"><br></font></blockquote><div><br>The 'Ub' mode doesn't work for '\r' on python 3. This may be a bug in python, as it works just fine on python 2.7. It may indeed be desirable to read the files as text, but that would require more work on both loadtxt and genfromtxt.<br>
<br>Chuck<br></div></div>