1
I made a code that should take the number of rows of a txt file and then use this same number of rows in a while to convert columns and rows into array.
lines = 0
ln = 0
for line in dataset:
line = line.strip()
lines += 1
print (lines, ln)
while ln < (lines):
line1 = dataset.readline()
if not line1: break
words = str.split(line1)
ln += 1
In the case I am working, the file has 551 lines, but the code always ends when the ln reaches 275
Have you seen what’s on line 275? It may be that the content is making the expression true
if not line1: break
try to usefor ln in range(lines)
instead ofwhile
– Sidon