On May 27, 2009, at 5:53 PM, Fernando Perez wrote:
Howdy,
I'm wondering if the code below illustrates a bug in loadtxt, or just a 'live with it' limitation.
Have you tried np.lib.io.genfromtxt ? dt = dtype(dict(names=['name','x','y','block'], formats=['S4',float,float,(int,(2,3))])) txtdata = StringIO(""" # name x y block - 2x3 ints aaaa 1.0 8.0 1 2 3 4 5 6 aaaa 2.0 7.4 2 11 22 3 4 5 6 bbbb 3.5 8.5 3 0 22 44 5 6 aaaa 6.4 4.0 4 1 3 33 54 65 aaaa 8.8 4.1 5 5 3 4 44 77 bbbb 5.5 9.1 6 3 4 5 0 55 bbbb 7.7 8.5 7 2 3 4 5 66 """) alt_data = np.lib.io.genfromtxt(txtdata,dtype=dt) array([('aaaa', 1.0, 8.0, [[1, 1, 1], [1, 1, 1]]), ('aaaa', 2.0, 7.4000000000000004, [[2, 2, 2], [2, 2, 2]]), ('bbbb', 3.5, 8.5, [[3, 3, 3], [3, 3, 3]]), ('aaaa', 6.4000000000000004, 4.0, [[4, 4, 4], [4, 4, 4]]), ('aaaa', 8.8000000000000007, 4.0999999999999996, [[5, 5, 5], [5, 5, 5]]), ('bbbb', 5.5, 9.0999999999999996, [[6, 6, 6], [6, 6, 6]]), ('bbbb', 7.7000000000000002, 8.5, [[7, 7, 7], [7, 7, 7]])], dtype=[('name', '|S4'), ('x', '<f8'), ('y', '<f8'), ('block', '<i4', (2, 3))]) Is this what you want?