<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FMSGJ%2FImport_table</id>
	<title>Module:Sandbox/MSGJ/Import table - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FMSGJ%2FImport_table"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/MSGJ/Import_table&amp;action=history"/>
	<updated>2026-04-21T04:48:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/MSGJ/Import_table&amp;diff=145772&amp;oldid=prev</id>
		<title>imported&gt;MSGJ at 20:49, 23 October 2022</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/MSGJ/Import_table&amp;diff=145772&amp;oldid=prev"/>
		<updated>2022-10-23T20:49:16Z</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;require(&amp;quot;strict&amp;quot;)&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.import(frame)&lt;br /&gt;
	local wikiqid = &amp;quot;Q328&amp;quot;&lt;br /&gt;
	local resolveEntity = require(&amp;quot;Module:ResolveEntityId&amp;quot;)._id&lt;br /&gt;
	local coord2text = require(&amp;quot;Module:Coordinates/sandbox&amp;quot;)._coord2text&lt;br /&gt;
	local args = frame.args or frame:getParent().args&lt;br /&gt;
	if not args.config then&lt;br /&gt;
		return &amp;quot;No configuation.&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	local config = {}&lt;br /&gt;
	for c1,col in ipairs(mw.text.split(args.config,&amp;quot;,&amp;quot;)) do&lt;br /&gt;
		config[c1] = mw.text.split(col,&amp;quot;-&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	if not args.page then&lt;br /&gt;
		return &amp;quot;No page specified.&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	local content = mw.title.new(args.page):getContent() -- read page specified&lt;br /&gt;
	content = string.match(content,&amp;quot;%{%|(.+)%|%}&amp;quot;) -- keep table only&lt;br /&gt;
	local rows = mw.text.split(content,&amp;quot;|-&amp;quot;,true) -- split table into rows&lt;br /&gt;
	local output = &amp;quot;&amp;quot;&lt;br /&gt;
	for rn,row in ipairs(rows) do&lt;br /&gt;
		local import = {}&lt;br /&gt;
		local qid&lt;br /&gt;
		local columns = mw.text.split(row,&amp;quot;|&amp;quot;) -- split table rom into columns&lt;br /&gt;
		table.remove(columns,1) -- remove content before the first | character&lt;br /&gt;
		--table.remove(columns,1) -- remove heading row&lt;br /&gt;
		for cn,col in ipairs(columns) do&lt;br /&gt;
			col = mw.text.trim(col)&lt;br /&gt;
			if config[cn] then&lt;br /&gt;
				if config[cn][1] == &amp;quot;label&amp;quot; then&lt;br /&gt;
					local rawarticle = string.match(col,&amp;#039;%[%[(.+)%|&amp;#039;) or string.match(col,&amp;#039;%[%[(.+)%]%]&amp;#039;)&lt;br /&gt;
					if rawarticle then&lt;br /&gt;
						qid = resolveEntity(rawarticle)&lt;br /&gt;
					end&lt;br /&gt;
				elseif config[cn][1] == &amp;quot;wikilink&amp;quot; then&lt;br /&gt;
					local rawarticle = string.match(col,&amp;#039;%[%[(.+)%|&amp;#039;) or string.match(col,&amp;#039;%[%[(.+)%]%]&amp;#039;)&lt;br /&gt;
					local val&lt;br /&gt;
					if rawarticle then&lt;br /&gt;
						val = resolveEntity(rawarticle)&lt;br /&gt;
						if val then&lt;br /&gt;
							import[#import+1] = {}&lt;br /&gt;
							import[#import].property = config[cn][2]&lt;br /&gt;
							import[#import].value = val&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				elseif config[cn][1] == &amp;quot;year&amp;quot; then&lt;br /&gt;
					import[#import+1] = {}&lt;br /&gt;
					import[#import].property = config[cn][2]&lt;br /&gt;
					import[#import].value = &amp;quot;+&amp;quot; .. col .. &amp;quot;-00-00T00:00:00Z/9&amp;quot;&lt;br /&gt;
				elseif config[cn][1] == &amp;quot;quantity&amp;quot; then&lt;br /&gt;
					import[#import+1] = {}&lt;br /&gt;
					col = string.gsub(col,&amp;quot;,&amp;quot;,&amp;quot;&amp;quot;) -- remove any commas&lt;br /&gt;
					import[#import].property = config[cn][2]&lt;br /&gt;
					if string.upper(string.sub(config[cn][3],1,1)) == &amp;quot;Q&amp;quot; then&lt;br /&gt;
						config[cn][3] = string.sub(config[cn][3],2)&lt;br /&gt;
					end&lt;br /&gt;
					import[#import].value = col .. &amp;quot;U&amp;quot; .. config[cn][3]&lt;br /&gt;
--				elseif config[cn][1] == &amp;quot;coord&amp;quot; then&lt;br /&gt;
--					import[#import+1] = {}&lt;br /&gt;
--					import[#import].property = config[cn][2]&lt;br /&gt;
--					import[#import].value = coord2text(col,&amp;quot;lat&amp;quot;) .. &amp;quot;/&amp;quot; .. coord2text(col,&amp;quot;long&amp;quot;)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if qid then&lt;br /&gt;
			local qslink = &amp;quot;&amp;quot;&lt;br /&gt;
			for cn = 1,#import do&lt;br /&gt;
				qslink = qslink .. qid .. &amp;quot;|&amp;quot; .. import[cn].property .. &amp;quot;|&amp;quot; .. import[cn].value .. &amp;quot;|S143|&amp;quot; .. wikiqid .. &amp;quot;||&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
			output = output .. &amp;#039;&amp;lt;span class=&amp;quot;qs&amp;quot;&amp;gt;[[File:Commons to Wikidata QuickStatements.svg|20px|link=https://quickstatements.toolforge.org/#/v1=&amp;#039; .. mw.uri.encode(qslink,&amp;quot;PATH&amp;quot;) .. &amp;#039;]]&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;MSGJ</name></author>
	</entry>
</feed>