Module:PickRow
Appearance
Documentation for this module may be created at Module:PickRow/doc
local p = {}
local column = 0
function p.pick_row(tab, args)
if tonumber(args.column) > 0 then
column = tonumber(args.column)
end
for i, row in ipairs(tab.data) do
if row[column] ~= args.filter then
for c, _ in ipairs(row) do
if tab.schema.fields[c].type == "number" then
row[c] = 0
end
end
end
end
return tab
end
-- Put p.test() in the debug console while you're editing the code to test
-- with a specific sample data set / args
function p.test(column, filter, tabname)
-- pass "_" for lang to get the raw multilingual source data
local tab = mw.ext.data.get(tabname or "Test.tab", "_", "LocalData")
local args = {
["column"] = column or 1,
["filter"] = filter or "Tijgertje I"
}
tab = p.pick_row(tab, args)
return mw.dumpObject(tab)
end
return p