I am reading lines from file in a list:
import numpy as np
lines = tuple(open('values.txt','r'))
x = np.array([line for line in lines])
values.txt looks like:
[1,0,1,0],
[1,0,0,0]
It throws an error:
valueError: invalid literal for float()
However, if I just assign the list to x, it works just fine.
How to take input from file in a numpy array?
linefrom the file is a string, not a list. See what you get whenfloat('[1,0]').