No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p. | function p.parseCSV(input) | ||
local array = {} | |||
local | local i = 1 | ||
-- Split the input by lines | |||
for line in mw.text.split(input, "\n") do | |||
array[i] = {} | |||
-- Split the | local j = 1 | ||
for line in | |||
-- Split each line by commas | |||
-- Split each line | for cell in mw.text.split(line, ",") do | ||
for | array[i][j] = mw.text.trim(cell) | ||
j = j + 1 | |||
end | end | ||
i = i + 1 | |||
end | end | ||
return array | |||
end | |||
function p.getTable(input) | |||
return | local array = p.parseCSV(input) | ||
return array[1][1] | |||
end | end | ||
return p | return p | ||
Revision as of 03:18, 4 June 2024
Documentation for this module may be created at Module:ModuleLevelTable/doc
local p = {}
function p.parseCSV(input)
local array = {}
local i = 1
-- Split the input by lines
for line in mw.text.split(input, "\n") do
array[i] = {}
local j = 1
-- Split each line by commas
for cell in mw.text.split(line, ",") do
array[i][j] = mw.text.trim(cell)
j = j + 1
end
i = i + 1
end
return array
end
function p.getTable(input)
local array = p.parseCSV(input)
return array[1][1]
end
return p