I have a file with text with only 0's and 1's. No space between them. Example:
0101110
1110111
I would like to read a character at a time and place them as a single element in a list of integers.
My code:
intlist = []
with open('arq.txt', 'r') as handle:
for line in handle:
if not line.strip():
continue
values = map(int, line.split())
intlist.append(values)
print intlist
handle.close()
My result:
[[101110], [1110111]]
Like if I transform the 0101110 in intlist = [0,1,0,1,1,1,0,1,1,1,0,1,1,1]. (without '\n')