Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not completed file reading

Tags:

file-io

lua

I'm trying to print the number of rows in my file training.txt but found out that my code does not read the whole file. Code goes like this:

row = 1
for line in io.lines 'training.txt' do
    row = row + 1
end
print(row)

I tried changing the file with test.txt that has the same format with training.txt and file reading worked fine, reads until the end of file. So maybe the problem is with my text file? But how? It has the same format.

Text files are uploaded here for testing.

like image 251
Rachelle Avatar asked Nov 26 '25 06:11

Rachelle


1 Answers

The file you uploaded training.txt is not the same format as test.txt, it does not have newline characters that indicate the EOL (End of Line). Try opening it in notepad to see the difference.

like image 114
Yussuf S Avatar answered Nov 28 '25 21:11

Yussuf S