I am having trouble to read a matrix from a text file to a numpy array very fast without any unnecessary copying.
The format is the following:
3
1 -1 6 5 9 7 0 -7
0 -5 -5 3 -7 -2 4 3
-2 -9 -5 6 6 -2 -9 9
-7 -3 3 -3 3 8 8 -8
9 3 5 2 -2 4 6 5
-1 -8 7 -4 -1 3 7 4
0 -4 -8 -3 2 6 2 -2
-1 8 6 5 9 8 0 6
The first line (3) indicates the size of the matrix i.e here it is 2^3 = 8x8 matrix
Each column is separated with a \t character and each line is separated with a \n character.
I have tried numpy.loadtxt(), I can specify the row delimiter, skip the first row (the 3) but then I need to specify a column delimiter. Can anyone help please?
np.loadtxt(<path-to-file>, skiprows=1)should work, what is it giving you?loadtxt,delimitersplits columns. You can't specify a row delimiter. That should be a straight forward load.