So Basically this is the text in the txt file:
hello, school, tommy, house, homemaking
I Want to put it into an Array So it looks like:
Array = {'hello', 'school', 'tommy', 'house', 'homemaking'}
and Not Like:
Array = {'hello, school, tommy, house, homemaking'}
With Lua 5.4 you can do a combination of load()
io.open()
and preparing it with three gsub()
on the fly to convert the file content...
> array = load("return " .. io.open('text.txt', 'r'):read('*a'):gsub('^.', '{%1'):gsub('.$', '%1}'):gsub('%w+', '"%1"'))()
> print(#array)
5
> print(table.concat(array,'\n'))
hello
school
tommy
house
homemaking
The three gsub() do...
{ + first sign
last sign + }
"word"
{"hello", "school", "tommy", "house", "homemaking"
}