A unified csv2ini converter

Get some help with creating maps or modding.
Need a map editor or other tools, look here!
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

A unified csv2ini converter

Post 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 (:
Last edited by NoQ on 18 May 2013, 04:50, edited 2 times in total.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: A unified csv2ini converter

Post by Per »

Here is the code I used to convert features.txt... Don't laugh, it got the job done :-)
Attachments
test.c
Do not use for teaching purposes
(1.61 KiB) Downloaded 325 times
User avatar
bendib
Regular
Regular
Posts: 1011
Joined: 29 Aug 2010, 05:22
Location: Imeuta
Contact:

Re: A unified csv2ini converter

Post 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.
Attachments
test.c
Updated to show Per a few nice tips in coding.
(2.38 KiB) Downloaded 300 times
Also known as Subsentient.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: A unified csv2ini converter

Post 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.
User avatar
Iluvalar
Regular
Regular
Posts: 1828
Joined: 02 Oct 2010, 18:44

Re: A unified csv2ini converter

Post 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...
Heretic 2.3 improver and proud of it.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: A unified csv2ini converter

Post 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.
User avatar
Iluvalar
Regular
Regular
Posts: 1828
Joined: 02 Oct 2010, 18:44

Re: A unified csv2ini converter

Post 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.
Heretic 2.3 improver and proud of it.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: A unified csv2ini converter

Post 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.
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: A unified csv2ini converter

Post 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.
http://addons.wz2100.net/ developer
User avatar
Iluvalar
Regular
Regular
Posts: 1828
Joined: 02 Oct 2010, 18:44

Re: A unified csv2ini converter

Post 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 ?
Heretic 2.3 improver and proud of it.
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: A unified csv2ini converter

Post 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!
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: A unified csv2ini converter

Post 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.
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: A unified csv2ini converter

Post by Berg »

NoQ wrote:What's the plan then? Command me.
STOP USING TAB USE 4 SPACES
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: A unified csv2ini converter

Post 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.
http://addons.wz2100.net/ developer
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: A unified csv2ini converter

Post 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.
Last edited by NoQ on 05 Oct 2013, 12:37, edited 1 time in total.
Post Reply