|
Hello,
I'd like to create a table, which contains sub-tables, from a file.
Here is my test file:
$ cat table.txt
foo = { "value foo 1", "value foo 2", name="i'm foo"}
bar = { "value bar 1", "value bar 2", name="i'm bar"}
And here is my Lua source file:
$ cat do_table.lua
#!/usr/bin/env lua
local t={}
for line in io.lines("table.txt") do
t[#t+1]={line}
end
for _,subtable in pairs(t) do
for k,v in pairs(subtable) do
print(k,v)
end
end
If i launch this script, i get this:
$ ./do_table.lua
1 foo = { "value foo 1", "value foo 2", name="i'm foo"}
1 bar = { "value bar 1", "value bar 2", name="i'm bar"}
but that's not what i expected.
I want to have this, instead:
1 foo = table 0x12345689
2 bar = talbe 0x23456780
Is this a problem of interpretation of the line i read ?
Thank you.