line.read contains
25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40.25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40.25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40.25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40
My single line reader is here
output = open('line.read', 'r') # See the r
nodes_list = output.read().strip().split('.')
mylist = [[int(cell) for cell in row.split(',')] for row in nodes_list]
My output is in this code.
['25,26,27,28,29,30,31,32', '33,34,35,36,37,38,39,40', '25,26,27,28,29,30,31,32', '33,34,35,36,37,38,39,40', '25,26,27,28,29,30,31,32', '33,34,35,36,37,38,39,40', '25,26,27,28,29,30,31,32', '33,34,35,36,37,38,39,40']
This code reads only one line however i want to read multiple lines and convert it to 8x8 integer array. Old value is not important for me. I just want to read current line. How can i do that ? It will read first line it will do smth after that it will look second line etc.
My txt will be something like this
25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40.25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40.25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40.25,26,27,28,29,30,31,32.33,34,35,36,37,38,39,40
22,33,21,33,40,37,24,23.15,13,12,35,33,12,15,23.22,33,21,33,40,37,24,23.15,13,12,35,33,12,15,23.22,33,21,33,40,37,24,23.15,13,12,35,33,12,15,23.22,33,21,33,40,37,24,23.15,13,12,35,33,12,15,23
...
I can find it by looking empty cell or i can put a special character to my txt file which can know end of the line. However, If i do this, it will read it as an string and also it shows all value. It should do that line by line. Thanks for helping