I have a text file with listed 4 x 3 binary values as such:
1 0 1
0 0 1
1 1 0
0 0 1
When I read this file in python, it is in this form:
import numpy as np
with open("test.txt")as g:
p=g.read().splitlines()
q=[];
for m in p:
q.append(int(m));
p=q;
Python window:
>>> p
['1 0 1', '0 0 1', '1 1 0', '0 0 1']
How to convert it into array:
array([[ 1.0, 0.0, 1.0],
[ 0.0, 0.0, 1.0],
[ 1.0, 1.0, 0.0],
[ 0.0, 0.0, 1.0]])