Reputation: 267
I have a separate folder Input
for the text files. i'm trying to read the lines in a certain file 'train.txt'. So how do i do it using this code?
for line in io.lines '???' do
end
Upvotes: 1
Views: 84
Reputation: 122383
io.lines
takes an optional argument to represent which file it iterates. Since this file is in a different folder, use an absolute path, or a proper relative path. For instance, in Unix-like system, you can use "/some/path/Input/train.txt"
.
for line in io.lines("/some/path/Input/train.txt") do
--print(line)
end
Upvotes: 1