Page 1 of 3

A unified csv2ini converter

Posted: 12 May 2013, 10:00
by NoQ
Trying to make one.

The conversion of the base game stats from txt (aka csv) to ini is almost finished. Afaik, it was accomplished by several people independently, each using their own automated conversion scripts for every file. What i'm trying to get is a single script to do all the conversion. I'm aiming at converting large stat mods such as Contingency, Ultimate Scavenger AI, or WZMini (the latter will probably require producing diffs as well, which will not be done by this script).
It's written in python3 and currently is capable of producing four ini files: body.ini, bodypropulsionimd.ini, construction.ini, weapons.ini.

If anybody has any useful snippets of code they used for converting, no matter how dirty, no matter in what language, please post it here. If anybody likes to join the github project, i'll provide commit access and/or accept pull requests (:

Re: A unified csv2ini converter

Posted: 12 May 2013, 12:06
by Per
Here is the code I used to convert features.txt... Don't laugh, it got the job done :-)

Re: A unified csv2ini converter

Posted: 12 May 2013, 12:25
by bendib
@Per: Elegant code in many ways, but some of the form is pretty sloppy. I cleaned it up a bit. Please read the comments. It now conforms to the C89 standard. I hope this is helpful.


P.S. I am one of the uninventive people who can write in C. I am dull in coming up with innovative or clever solutions, but good with the language itself.

Re: A unified csv2ini converter

Posted: 12 May 2013, 13:58
by NoQ
Thanks, features.ini now supported (:

These snippets help me understand what needs to be done. This time it was pretty straightforward, but in other cases some files get merged and sometimes new fields appear and old fields disappear, so i always need to be sure i didn't forget to work around these things.

Re: A unified csv2ini converter

Posted: 12 May 2013, 15:39
by Iluvalar
I just can't get it... Now the stat based mods look 25% bigger to transfer and you worked on program that read .CVS format anyway...

Re: A unified csv2ini converter

Posted: 12 May 2013, 15:46
by NoQ
Now the stat based mods look 25% bigger to transfer
I don't see how it is related to the topic.
you worked on program that read .CVS format anyway...
I don't see why you would expect that such program will not be needed during the 3.1->3.2 transition period.

Re: A unified csv2ini converter

Posted: 12 May 2013, 22:56
by Iluvalar
I'll try to rephrase my idea again.

Now that you worked on an homemade CVS reader, there was no point in the conversion at all. We could have stayed with the CVS format and use the reader when necessary. And keep the files smaller to transfer.

Re: A unified csv2ini converter

Posted: 13 May 2013, 00:01
by Per
Iluvalar wrote:I'll try to rephrase my idea again.

Now that you worked on an homemade CVS reader, there was no point in the conversion at all. We could have stayed with the CVSCSV format and use the reader when necessary. And keep the files smaller to transfer.
Please take the time to read the relevant discussions before voicing strong opinions.

You are, again, completely missing all the points.

As for file size, I mean, really. A standard map is bigger than any stats file, uncompressed, and the stats files compress like silly. And nothing is smaller than an ini diff -- if you are worried about a few kb on game startup, give some thanks to NoQ for that patch.

Re: A unified csv2ini converter

Posted: 13 May 2013, 00:44
by Duha
NoQ wrote:Trying to make one.
I start to make some. Now it is just collection of scripts.
Later I will combine them together to convert mod in one click.
https://github.com/Cjkjvfnby/wz_convertor (python 2.7)
It's written in python3 and currently is capable of producing four ini files: body.ini, bodypropulsionimd.ini, construction.ini, weapons.ini.
I think we should join.

Re: A unified csv2ini converter

Posted: 13 May 2013, 05:24
by Iluvalar
Per wrote: Please take the time to read the relevant discussions before voicing strong opinions.

You are, again, completely missing all the points.

As for file size, I mean, really. A standard map is bigger than any stats file, uncompressed, and the stats files compress like silly. And nothing is smaller than an ini diff -- if you are worried about a few kb on game startup, give some thanks to NoQ for that patch.
I only hosted thousands of self modded games last year. Maybe I was not relevant enough to be part of those discussions. Right... So many other people did the same. I guess it's hard to hear all the voices...

What is the link with ini diff ?

Re: A unified csv2ini converter

Posted: 13 May 2013, 06:07
by Berg
Iluvalar wrote: Per wrote:Please take the time to read the relevant discussions before voicing strong opinions.

You are, again, completely missing all the points.

As for file size, I mean, really. A standard map is bigger than any stats file, uncompressed, and the stats files compress like silly. And nothing is smaller than an ini diff -- if you are worried about a few kb on game startup, give some thanks to NoQ for that patch.


I only hosted thousands of self modded games last year. Maybe I was not relevant enough to be part of those discussions. Right... So many other people did the same. I guess it's hard to hear all the voices...

What is the link with ini diff ?
Your reply again does not reflect the topic you are replying to you claim knowledge about the conversion of csv to ini yet all you have input to this thread is "it will make the mod downloads bigger" .
Please stop your campaign to hold warzone advancement back.
Your claim to have hosted thousands of game is total crap going by the stats i have made up out of thin air like you often do your game have total 0.005 of total games played on the net.
Your not helping!

Re: A unified csv2ini converter

Posted: 13 May 2013, 06:24
by NoQ
Iluvalar wrote:Now that you worked on an homemade CVS reader, there was no point in the conversion at all.
We had one many years ago, and it was even built into the game. I still don't see what it changes.
Iluvalar wrote:What is the link with ini diff ?
This one, i guess.
Per wrote:And nothing is smaller than an ini diff
Well, one could quite well imagine a "csv diff" of "line,column,value" as in

Code: Select all

Ruin1,6,20
Ruin2,7,CHERRY.PIE
Would break whenever columns are added or removed or swapped around, but still not bad.
Duha wrote:I start to make some. Now it is just collection of scripts.
Later I will combine them together to convert mod in one click.
https://github.com/Cjkjvfnby/wz_convertor (python 2.7)

...

I think we should join.
Yay. Maybe. You're having nice upgrades conversion! :D
What's the plan then? Command me.

Re: A unified csv2ini converter

Posted: 13 May 2013, 07:42
by Berg
NoQ wrote:What's the plan then? Command me.
STOP USING TAB USE 4 SPACES

Re: A unified csv2ini converter

Posted: 13 May 2013, 07:45
by Duha
NoQ wrote: Yay. Maybe. You're having nice upgrades conversion! :D
What's the plan then? Command me.
I need a couple of days to add support for mod convert, think about structure add more scripts.

Re: A unified csv2ini converter

Posted: 13 May 2013, 08:16
by NoQ
As for structure, I didn't like the idea of trying to achieve less than one line of code per ini file field, as in some unpredictable places we could really use arbitrary flexibility, such as complicated guessing of new field values depending on multiple other field values from different files.

I don't think we need any zip file support here. Usually the modder will store the mod unpacked for easy tweaking and only pack it for release. So we just need to take the input folder and fill it with ini files.

The thing that bothers me is that some mods will have only a few files inside; they do not need to include dependencies we need. Eg. we need to look at names.txt to convert weapons.txt, but the mod that changes weapons.txt will not necessarily include a copy of names.txt; so we also need a way of specifying a base data directory, with lower priority.

p.s. diffs are not helpful in reducing file size, as they are mostly useful for small tweaks, while file size becomes a problem mostly for large total conversion mods.