I have a tsv file containing vibration data (with commas in place of dots for some silly reason, hence the converter). I'd like to generate numpy arrays from two of these channels, but get a "ValueError: too many values to unpack (expected 2)" that I can't figure out.
in ipython (with pylab option):
In [171] import re
In [172]: def qdsub(s):
.....: return re.sub('\,', '.', str(s)[2:-1])
.....:
In [173]: x, y = genfromtxt('QD1_short.tsv', delimiter='\t', usecols=(0, 1),
.....: unpack=True, skip_header=13, converters={0:qdsub, 1:qdsub},
.....: skip_footer=2, dtype=float)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-177-e17389233ac3> in <module>()
1 x, y = genfromtxt('QD1_short.tsv', delimiter='\t', usecols=(0, 1),
2 unpack=True, skip_header=13, converters={0:qdsub, 1:qdsub},
----> 3 skip_footer=2, dtype=float)
ValueError: too many values to unpack (expected 2)
The problem was in the converter, which apparently should return a float
def qdsub(s):
return float(re.sub('\,', '.', str(s)[2:-1]))