Page 1 of 1

CSV To INI

Posted: 01 Mar 2013, 02:09
by milo christiansen
A simple csv to ini converter

For every different type of csv file you need to convert to ini you will need to write a xml conversion specification, examples are included in the package.

Included are binarys for Windows in both 32 and 64 bit. Everybody else can just go compile it themselves :wink:
More info in the readme.

To generate an ini file from the contents of more than one csv file you will need more than one pass. Details in the readme.

If more flexability is needed just ask.

Re: CSV To INI

Posted: 01 Mar 2013, 02:26
by Goth Zagog-Thou
Will try this out immediately. Thanks Milo. :D

Re: CSV To INI

Posted: 01 Mar 2013, 02:41
by milo christiansen
Have fun :wink:

Re: CSV To INI

Posted: 01 Mar 2013, 08:47
by Reg312
windows users also can try this: https://github.com/crabster/Warzone-Sta ... sConverter
(source code included)
supports conversion for research.ini and structure.ini

Re: CSV To INI

Posted: 06 Mar 2013, 00:21
by Goth Zagog-Thou
Milo, I have no idea what to do with those .xml files, buddy. Sorry.

Re: CSV To INI

Posted: 06 Mar 2013, 02:59
by Goth Zagog-Thou
It seems that the crabster github no longer exists. Shame.

Re: CSV To INI

Posted: 06 Mar 2013, 07:16
by effigy
Eh? Crabster... :(

Re: CSV To INI

Posted: 06 Mar 2013, 19:49
by Originway
effigy wrote:Eh? Crabster... :(
rage quit?
O_o

Re: CSV To INI

Posted: 08 Mar 2013, 23:03
by milo christiansen
@Goth: Simple, let me go get a copy...

Note that this is for version 2

Code: Select all

<section> 
    <!-- NCA code to generate section name. Runs once per record. -->
    <namecode>(fmtstr "Record Number:%d Field 0:%s" (getrecord) (getfield 0)</namecode>

<key> 
    <index>1</index> <!-- csv field number to use for this key's value -->
     <name>test1</name> <!-- this keys name -->
</key>
</section>
The namecode tag has some simple code to generate the section name, for most cases you just need to put "(getfield 0)" here. That will get the first field in the record and make it the section name. (a record is a line in csv)

Then for each key in the section you need a key tag. index is the record number to use for that key's value and name is the string to use as the name for that key.

Run the example and look at the output, it's very simple.

A simple example:
csv file:

Code: Select all

test #1,1,2,3,4,5
test #2,1,2,3,4,5
test #3,1,2,3,4,5
test #4,1,2,3,4,5
test #5,1,2,3,4,5
xml file:

Code: Select all

<section>
	<!-- NCA code to generate section name. Runs once per record. -->
	<namecode>(getfield 0)</namecode>
	
	<key>
		<index>1</index> <!-- csv field number to use for this key's value -->
		<name>test1</name> <!-- this keys name -->
	</key>
	<key>
		<index>2</index>
		<name>test2</name>
	</key>
	<key>
		<index>3</index>
		<name>test3</name>
	</key>
	<key>
		<index>4</index>
		<name>test4</name>
	</key>
	<key>
		<index>5</index>
		<name>test5</name>
	</key>
</section>
Result:

Code: Select all

[test #1]
test1=1
test2=2
test3=3
test4=4
test5=5

[test #2]
test1=1
test2=2
test3=3
test4=4
test5=5

[test #3]
test1=1
test2=2
test3=3
test4=4
test5=5

[test #4]
test1=1
test2=2
test3=3
test4=4
test5=5

[test #5]
test1=1
test2=2
test3=3
test4=4
test5=5

Re: CSV To INI

Posted: 15 Mar 2013, 01:10
by Originway
Originway wrote:
effigy wrote:Eh? Crabster... :(
rage quit?
O_o
he still holding a grudge?

Re: CSV To INI

Posted: 20 Mar 2013, 17:16
by milo christiansen
If anyone makes a conversion descriptor file, post it here, that way I know which ones I can skip when I get around to making them :wink: