I need to take an array and split it column wise by known widths.
Say I have an array:
>>> arr
array([[b'13456789'],
[b'45678912']], dtype='|S8')
I need to convert it by widths know prior:
>>> arr
array([[b'13', b'456', b'7', b'89'],
[b'45', b'678', b'9', b'12']],
dtype=[('a', '|S2'), ('b', '|S3'), ('c', '|S1'), ('d', '|S2')])
Using numpy.genfromtxt would seem ideal, but I'm reading in from a binary file that has data encoding as strings after a 160 byte header other data that is not encoding as strings, so I use struct.unpack for them. However, numpy.genfromtxt doesn't seem to support binary files or have an offset parameter; but it does have the delimiter parameter that is useful.