Difference between revisions of "Module:TNT"
Jump to navigation
Jump to search
use ipairs to guarantee iteration over integer keys starting at 1 (pairs happens to iterate that way very often, but a case where it does not has been reported on the talk page)
en>Bawolff (Give a more useful error message if jsonconfig is missing. There have been three questions about this on the support desk from third party folks copying this template.) |
en>Erutuon (use ipairs to guarantee iteration over integer keys starting at 1 (pairs happens to iterate that way very often, but a case where it does not has been reported on the talk page)) |
||
Line 96: | Line 96: | ||
local data = loadData(dataset) | local data = loadData(dataset) | ||
local names = {} | local names = {} | ||
for _, field in | for _, field in ipairs(data.schema.fields) do | ||
table.insert(names, field.name) | table.insert(names, field.name) | ||
end | end | ||
Line 102: | Line 102: | ||
local params = {} | local params = {} | ||
local paramOrder = {} | local paramOrder = {} | ||
for _, row in | for _, row in ipairs(data.data) do | ||
local newVal = {} | local newVal = {} | ||
local name = nil | local name = nil | ||
for pos, val in | for pos, val in ipairs(row) do | ||
local columnName = names[pos] | local columnName = names[pos] | ||
if columnName == 'name' then | if columnName == 'name' then |