<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ABuildTableFromCSV</id>
	<title>API:BuildTableFromCSV - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ABuildTableFromCSV"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:BuildTableFromCSV&amp;action=history"/>
	<updated>2026-10-18T04:52:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.returnofreckoning.com/index.php?title=API:BuildTableFromCSV&amp;diff=30187&amp;oldid=prev</id>
		<title>Maintenance script: UI Lua API import (WAR 1.4.8)</title>
		<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:BuildTableFromCSV&amp;diff=30187&amp;oldid=prev"/>
		<updated>2026-10-16T19:40:37Z</updated>

		<summary type="html">&lt;p&gt;UI Lua API import (WAR 1.4.8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{LuaApi|group=Interface}}&lt;br /&gt;
Reads a CSV file from the game data and stores its rows in a Lua table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BuildTableFromCSV(csvPath, luaTableName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;csvPath : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Path of the CSV file in the game data, for example &amp;lt;code&amp;gt;&amp;quot;data\\gamedata\\pregame_features.csv&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
;luaTableName : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Path of the Lua table to fill, for example &amp;lt;code&amp;gt;&amp;quot;PregameFeatureList&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Nothing.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* The first line of the file is the header. It gives the field names.&lt;br /&gt;
* Every following line becomes one entry: &amp;lt;code&amp;gt;&amp;#039;&amp;#039;luaTableName&amp;#039;&amp;#039;[&amp;#039;&amp;#039;id&amp;#039;&amp;#039;][&amp;#039;&amp;#039;fieldName&amp;#039;&amp;#039;] = &amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; is the first cell of the line read as a whole number, and each further cell is stored under the field name from the same column of the header.&lt;br /&gt;
* Cell values are converted like this:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Cell !! Stored as&lt;br /&gt;
|-&lt;br /&gt;
| digits, optionally starting with &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; and with at most one &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; (any case) || &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| anything else || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Reading stops at the first line whose first cell cannot be read.&lt;br /&gt;
* Cells longer than 511 characters are cut.&lt;br /&gt;
* The function needs at least two arguments and only reads the last two. Both must be strings.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;BuildTableFromCSV&amp;#039;: Unable to open CSV File %s&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
From &amp;lt;code&amp;gt;interfacecore/source/characterselectwindow.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BuildTableFromCSV(&amp;quot;data\\gamedata\\pregame_features.csv&amp;quot;, &amp;quot;PregameFeatureList&amp;quot;)&lt;br /&gt;
...&lt;br /&gt;
-- Loop through each feature in the CSV and Populate the Data Structures&lt;br /&gt;
for _, featureData in ipairs( PregameFeatureList )&lt;br /&gt;
do&lt;br /&gt;
    local career = GameData.CareerLine[featureData.FEATURE_CAREER]&lt;br /&gt;
    local gender = GameData.Gender[featureData.FEATURE_GENDER]&lt;br /&gt;
    local featureName = GetPregameString( StringTables.Pregame[featureData.FEATURE_LABEL] )&lt;br /&gt;
    ...&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
PregameFeatureList = nil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:LoadStringTable|LoadStringTable]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>