I have a textfile, randomfile.txt, containing a lot of values separated with blankstep, basically one single long line of different numbers.
10 20 30 40 50 10 45 65.......
I’m using numpy.loadtxt to read all the values into python. What I want to do next is divide the long line of numbers into a 2-dimensional numpy array with four columns.
I want the array structure to be the following:
[10, 20, 30, 40]
[50, 10, 45, 65]
I have tried to use numpy.reshape to modify the array, but the problem is that the values are read-in as a single line of code.
I’d be thankful for suggestions on how to solve this, or tips of tutorials I could dig myself into.
The following line :
gets me the following output :
with your sample data.