I am trying to read a file and create an array from it. The file is as follows:
1 0
0 1
The code is:
line = file.read()
array = np.fromstring(line.strip(),dtype = bool, sep = " ")
array.resize(2,2)
print array
The output is:
[[ True False]
[False True]]
but there is always an extra space before 'True.' Does anyone know how to remove it?
printisn't a good way to serialize an array. Tryprint numpy.zeros([1001])to see why.