Note that there are some explanatory texts on larger screens.

plurals
  1. POLua accessing table stored in external file
    primarykey
    data
    text
    <p>I have an external lua file that has a table stored in it that is formatted as follows:</p> <pre><code>sgeT = { 2535047 = { { ["account"] = "TG-MCB110105", ["exec"] = "/share/home/00288/tg455591/NAMD_2.8b3/NAMD_2.8b3_Linux-x86_64-MVAPICH-Intel-Ranger/namd2", ["execEpoch"] = 1305825864, ["execModify"] = "Thu May 19 12:24:24 2011", ["execType"] = "user:binary", ["jobID"] = "2535047", ["numCores"] = "128", ["numNodes"] = "8", pkgT = { }, ["runTime"] = "65125", ["sha1"] = "e157dd510a7be4d775d6ceb271373ea24e7f9559", sizeT = { ["bss"] = "104552", ["data"] = "192168", ["text"] = "10650813", }, ["startEpoch"] = "1335843433", ["startTime"] = "Mon Apr 30 22:37:13 2012", ["user"] = "guo", }, }, 2535094 = { { ["account"] = "TG-MCB110105", ["exec"] = "/share/home/00288/tg455591/NAMD_2.8b3/NAMD_2.8b3_Linux-x86_64-MVAPICH-Intel-Ranger/namd2", ["execEpoch"] = 1305825864, ["execModify"] = "Thu May 19 12:24:24 2011", ["execType"] = "user:binary", ["jobID"] = "2535094", ["numCores"] = "128", ["numNodes"] = "8", pkgT = { }, ["runTime"] = "81635", ["sha1"] = "e157dd510a7be4d775d6ceb271373ea24e7f9559", sizeT = { ["bss"] = "104552", ["data"] = "192168", ["text"] = "10650813", }, ["startEpoch"] = "1335823028", ["startTime"] = "Mon Apr 30 16:57:08 2012", ["user"] = "guo", }, } </code></pre> <p>I want to iterate through the table like an array and return the exec key, value pair, and I am completely new to lua and I am using the following script:</p> <pre><code>FileStr = "lariatData-sgeT-2012-05-31.lua" Hnd, ErrStd = io.open(FileStr, "r") myTable = loadTable(FileStr) if Hnd then for Str in Hnd:lines() do print(Str, "\n") for exec, val in pairs(myTable) do print(exec.." "..val, "\n") end end Hnd.close() else print(ErrStr, "\n") end </code></pre> <p>However, it is returning that the table is nil. What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload