Module:Oricon

local p = {} function p.OriconWeek(frame) local WeekData = frame.args[1] _, _, d1, d2, d3, d4, d5, d6, d7, w1 = string.find(WeekData, "(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.*)") output = "|-\n" output = output .. "| " .. ProcessDay(d1) .. "\n" output = output .. "| " .. ProcessDay(d2) .. "\n" output = output .. "| " .. ProcessDay(d3) .. "\n" output = output .. "| " .. ProcessDay(d4) .. "\n" output = output .. "| " .. ProcessDay(d5) .. "\n" output = output .. "| " .. ProcessDay(d6) .. "\n" output = output .. "| " .. ProcessDay(d7) .. "\n" output = output .. "| " .. ProcessWeek(w1) .. "\n" return output end function ProcessDay (Day) _, count = string.gsub(Day, "/", "/") if count==0 then return Day else _, _, rank, sales = string.find(Day, "(%d*)/(%d*)") sales = sales + 0 --turn into number for further formatting sales = comma_value(sales) return rank .. " " .. sales .. " "   end end function ProcessWeek (Week) _, count = string.gsub(Week, "/", "/") if count==0 then return Week .. " | " else _, _, rank, sales = string.find(Week, "(%d*)/(%d*)") sales = sales + 0 --turn into number for further formatting sales = comma_value(sales) return rank .. "\n| " .. sales end end function comma_value(amount) local formatted = amount while true do     formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end return p