No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function parseCSV(csv) | |||
local result = {} | |||
local cell = "" | |||
local inQuotes = false | |||
for i = 1, #csv do | |||
local char = csv:sub(i, i) | |||
if char == '"' then | |||
inQuotes = not inQuotes | |||
elseif char == '@' and not inQuotes then | |||
table.insert(result, cell) | |||
cell = "" | |||
elseif char == '\n' and not inQuotes then | |||
table.insert(result, cell) | |||
cell = "" | |||
else | |||
cell = cell .. char | |||
end | |||
end | |||
if cell == "" then | |||
cell = "Q" | |||
end | |||
table.insert(result, cell) | |||
return result | |||
end | |||
function p.processData(frame) | function p.processData(frame) | ||
Line 9: | Line 39: | ||
local result = "Name: " .. name .. name .. name .. ", Property2: " .. property2 | local result = "Name: " .. name .. name .. name .. ", Property2: " .. property2 | ||
return | return frame.args[0] | ||
end | end | ||
return p | return p |
Revision as of 06:01, 5 June 2024
Documentation for this module may be created at Module:ModuleUniqueStatTable/doc
local p = {} function parseCSV(csv) local result = {} local cell = "" local inQuotes = false for i = 1, #csv do local char = csv:sub(i, i) if char == '"' then inQuotes = not inQuotes elseif char == '@' and not inQuotes then table.insert(result, cell) cell = "" elseif char == '\n' and not inQuotes then table.insert(result, cell) cell = "" else cell = cell .. char end end if cell == "" then cell = "Q" end table.insert(result, cell) return result end function p.processData(frame) local property1 = frame.args.property1 or "" local property2 = frame.args.property2 or "" local name = frame.args.name or "DNE" -- Process the data local result = "Name: " .. name .. name .. name .. ", Property2: " .. property2 return frame.args[0] end return p