I'm writing a Python script reading an input file, line by line, each containing 20 values. I'm trying to store the first one in a 1D array, and the 19 others in a second array.
They have been defined as:
x = numpy.zeros((n_lines))
y = numpy.zeros((n_lines,19))
n_lines the number of lines in my input file. and I'm reading it with
for i,line in enumerate(open(infile)):
x[i],y[i] = line.split(' ')
But I'm encountering an Too many values to unpack error
I'm now doing it by storing it in one single large array and then cutting it into two in the end. I'm not using line.split(' ')[0],line.split(' ')[1:]
as it doesn't look optimized to split twice.
Is there a neat (Pythonista) way of unpacking?
(I'm using Python 2.7 if that matters)