i want to feed my data into a (n,4,5) python numpy array. are there any simple solutions?
i've format my data so that each line of the file looks like a python array, but its hard to read it as a python array, for example:
[0,0,0,1,1],[0,0,0,0,0],[0,1,1,0,0],[1,0,0,0,0] //line1
[1,0,0,1,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0] //line2
...
desire output:
myarray=[[[0,0,0,1,1],[0,0,0,0,0],[0,1,1,0,0],[1,0,0,0,0]],[[1,0,0,1,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0]]...]
seems strip, eval and json all not working well.. please help
i've also tried:
with open('filename') as f:
data = f.readlines()
data = [x.strip() for x in data]
array=[]
for i in data:
a=split(r'(?<=\]),(?=\[)',i )
array.append(a)
data=np.array((array))