Sure, I will.  Right now my solution is to use genfromtxt once with bytes and auto-dtype detection, then modify the resulting dtype, replacing bytes with unicodes, and use that new dtypes for a second round of genfromtxt.  A bit awkward but that gets the job done.<div>
Antony Lee<br><br><div class="gmail_quote">2012/5/1 Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div><div class="h5">On Fri, Apr 27, 2012 at 8:17 PM, Antony Lee <span dir="ltr"><<a href="mailto:antony.lee@berkeley.edu" target="_blank">antony.lee@berkeley.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>With bytes fields, genfromtxt(dtype=None) sets the sizes of the fields to the largest number of chars (npyio.py line 1596), but it doesn't do the same for unicode fields, which is a pity.  See example below.</div>


<div>I tried to change npyio.py around line 1600 to add that but it didn't work; from my limited understanding the problem comes earlier, in the way StringBuilder is defined(?).</div><div>Antony Lee</div><div><br></div>


<div>import io, numpy as np</div><div>s = io.BytesIO()</div><div>s.write(b"abc 1\ndef 2")</div><div>s.seek(0)</div><div>t = np.genfromtxt(s, dtype=None) # (or converters={0: bytes})</div><div>print(t, t.dtype) # -> [(b'a', 1) (b'b', 2)] [('f0', '|S1'), ('f1', '<i8')]</div>


<div>s.seek(0)</div><div>t = np.genfromtxt(s, dtype=None, converters={0: lambda s: s.decode("utf-8")})</div><div>print(t, t.dtype) # -> [('', 1) ('', 2)] [('f0', '<U0'), ('f1', '<i8')]</div>


<br></blockquote></div></div><div><br>Could you open a ticket for this?<br><br>Chuck <br></div><br></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>