<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://the.satanic.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AAutocalctable</id>
	<title>Module:Autocalctable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://the.satanic.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AAutocalctable"/>
	<link rel="alternate" type="text/html" href="https://the.satanic.wiki/index.php?title=Module:Autocalctable&amp;action=history"/>
	<updated>2026-04-20T02:56:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://the.satanic.wiki/index.php?title=Module:Autocalctable&amp;diff=11054&amp;oldid=prev</id>
		<title>WikiGOD at 05:23, 2 May 2021</title>
		<link rel="alternate" type="text/html" href="https://the.satanic.wiki/index.php?title=Module:Autocalctable&amp;diff=11054&amp;oldid=prev"/>
		<updated>2021-05-02T05:23:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:23, 2 May 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l9&quot;&gt;Line 9:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 9:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local p = {}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local p = {}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local csv = require(&quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Dev&lt;/del&gt;:Csv&quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local csv = require(&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Module&lt;/ins&gt;:Csv&quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local json = require(&quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Dev&lt;/del&gt;:Json&quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local json = require(&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Module&lt;/ins&gt;:Json&quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local getArgs = require(&quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Dev&lt;/del&gt;:Arguments&quot;).getArgs&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local getArgs = require(&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Module&lt;/ins&gt;:Arguments&quot;).getArgs&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--%  Extracts table columns containing numbers&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--%  Extracts table columns containing numbers&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key zzegtzyr_mw19226-mwjf_:diff:1.41:old-10864:rev-11054:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>WikiGOD</name></author>
	</entry>
	<entry>
		<id>https://the.satanic.wiki/index.php?title=Module:Autocalctable&amp;diff=10864&amp;oldid=prev</id>
		<title>WikiGOD: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://the.satanic.wiki/index.php?title=Module:Autocalctable&amp;diff=10864&amp;oldid=prev"/>
		<updated>2021-04-30T02:23:47Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:23, 30 April 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key zzegtzyr_mw19226-mwjf_:diff:1.41:old-10863:rev-10864 --&gt;
&lt;/table&gt;</summary>
		<author><name>WikiGOD</name></author>
	</entry>
	<entry>
		<id>https://the.satanic.wiki/index.php?title=Module:Autocalctable&amp;diff=10863&amp;oldid=prev</id>
		<title>Mediawiki&gt;Magiczocker01 at 16:40, 24 April 2021</title>
		<link rel="alternate" type="text/html" href="https://the.satanic.wiki/index.php?title=Module:Autocalctable&amp;diff=10863&amp;oldid=prev"/>
		<updated>2021-04-24T16:40:04Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&amp;lt;pre&amp;gt;&lt;br /&gt;
--|Description : Autocalctable&lt;br /&gt;
--|Adds summation/average/min/max values of a column of a table imported from json/module/csv page&lt;br /&gt;
--|Syntax :&lt;br /&gt;
--|{{#invoke:Autotablecalc|page=pagename|type=datatype|calc=calculationtype}}&lt;br /&gt;
--|Where calc = sum/avg/min/max - can be more than one separated by commas ,e.g. calc=sum,avg&lt;br /&gt;
--| pagename = name of page/module&lt;br /&gt;
--| datatype = json or lua or cvs&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local csv = require(&amp;quot;Dev:Csv&amp;quot;)&lt;br /&gt;
local json = require(&amp;quot;Dev:Json&amp;quot;)&lt;br /&gt;
local getArgs = require(&amp;quot;Dev:Arguments&amp;quot;).getArgs&lt;br /&gt;
&lt;br /&gt;
--%  Extracts table columns containing numbers&lt;br /&gt;
--@ sPage (string) A page containing the table e.g Module:Scores.json&lt;br /&gt;
--@ sType (string) The type of data contained in the page (csv, json, lua) -lua table&lt;br /&gt;
--: (string) A table containing calculated columns&lt;br /&gt;
local function getTable(sPage, sType)&lt;br /&gt;
	if sPage then&lt;br /&gt;
		if sType == &amp;quot;lua&amp;quot; then&lt;br /&gt;
			return require(sPage)&lt;br /&gt;
		elseif sType == &amp;quot;csv&amp;quot; then&lt;br /&gt;
			return csv.convertToLua(sPage)&lt;br /&gt;
		end&lt;br /&gt;
		local oData = mw.title.new(sPage):getContent()&lt;br /&gt;
		if oData and sType == &amp;quot;json&amp;quot; then&lt;br /&gt;
			return json.decode(oData)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--% Entry point - Creates a table with automatically calculated columns&lt;br /&gt;
--@ frame (table) A scribunto frame&lt;br /&gt;
--: (string) A table containing calculated columns&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local sPageName = args.page&lt;br /&gt;
	local sType = args.type&lt;br /&gt;
	local calculations = args.calc&lt;br /&gt;
	local calcTable = getTable(sPageName, sType)&lt;br /&gt;
	&lt;br /&gt;
	return p.createHtmlTable(calcTable, calculations)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--% Creates an html table&lt;br /&gt;
--@ arrColumns (string) A column containing numbers&lt;br /&gt;
--@ calculations (string) The types of calculations to perform (avg, min, max, sum)&lt;br /&gt;
--: (string) An html table containing calculated columns&lt;br /&gt;
function p.createHtmlTable(arrColumns, calculations)&lt;br /&gt;
	if not arrColumns then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local hTable = mw.html.create(&amp;quot;table&amp;quot;)&lt;br /&gt;
	local storedData = {}&lt;br /&gt;
	local calc = {sum = {0}, avg = {0}, min = {0}, max = {0}, elements = {}}&lt;br /&gt;
	&lt;br /&gt;
	for i in ipairs(arrColumns) do &lt;br /&gt;
		local sTag = i == 1 and &amp;quot;th&amp;quot; or &amp;quot;td&amp;quot;&lt;br /&gt;
		hTable:tag(&amp;quot;tr&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		for sKey, sData in ipairs(arrColumns[i]) do&lt;br /&gt;
			storedData[sKey] = storedData[sKey] or {}&lt;br /&gt;
			&lt;br /&gt;
			hTable:tag(sTag)&lt;br /&gt;
				:wikitext(sData)&lt;br /&gt;
			-- //gets second row because the first one is the heading&lt;br /&gt;
			if tonumber(sData) and i &amp;gt; 1 then&lt;br /&gt;
				storedData[sKey][#storedData[sKey] + 1] = tonumber(sData)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local val&lt;br /&gt;
	&lt;br /&gt;
	for index, dataTable in pairs(storedData) do&lt;br /&gt;
		for _, value in pairs(dataTable) do&lt;br /&gt;
			val = value or 0&lt;br /&gt;
			calc.sum[index] = (calc.sum[index] or 0) + val&lt;br /&gt;
			calc.min[index] = calc.min[index] or 0&lt;br /&gt;
			calc.max[index] = calc.max[index] or 0&lt;br /&gt;
			calc.avg[index] = calc.avg[index] or 0&lt;br /&gt;
			&lt;br /&gt;
			if calc.min[index] &amp;gt;= val then&lt;br /&gt;
				calc.min[index] = val&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			if calc.max[index] &amp;lt;= val then&lt;br /&gt;
				calc.max[index] = val&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		calc.elements[index] = #dataTable&lt;br /&gt;
		&lt;br /&gt;
		if calc.sum[index] &amp;gt; 0 then&lt;br /&gt;
			calc.avg[index] = calc.sum[index] / #dataTable&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local calcTable = mw.text.split(calculations or &amp;quot;&amp;quot;, &amp;quot;,&amp;quot;)&lt;br /&gt;
	local bFlag = true&lt;br /&gt;
	local trNode&lt;br /&gt;
	&lt;br /&gt;
	for _, calctype in pairs(calcTable) do&lt;br /&gt;
		if calc[calctype] then&lt;br /&gt;
			trNode = mw.html.create(&amp;quot;tr&amp;quot;)&lt;br /&gt;
			&lt;br /&gt;
			for sKey in ipairs(arrColumns[1]) do&lt;br /&gt;
				trNode:tag(&amp;quot;td&amp;quot;)&lt;br /&gt;
					:wikitext(calc[calctype][sKey])&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			if bFlag then&lt;br /&gt;
				trNode:css(&amp;quot;border-top&amp;quot;, &amp;quot;thick double #ff0000&amp;quot;)&lt;br /&gt;
				bFlag = false&lt;br /&gt;
			end&lt;br /&gt;
			hTable:node(trNode):done()&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	hTable:addClass(&amp;quot;wikitable&amp;quot;)&lt;br /&gt;
	hTable:done()&lt;br /&gt;
	&lt;br /&gt;
	return hTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Mediawiki&gt;Magiczocker01</name></author>
	</entry>
</feed>