The International Simutrans Forum

PakSets and Customization => General Resources and Tools => Tools => Topic started by: The Hood on January 18, 2016, 08:43:29 PM

Title: Dat file to spreadsheet reader/writer
Post by: The Hood on January 18, 2016, 08:43:29 PM
Presenting my latest project - a couple of Excel macros that read dat files into a spreadsheet so you can manipulate them easily for balancing, then write them back out as dat files. Written to help me balance pak128.Britain, they may be useful for others. Not really tested beyond the basics yet though.

Notes:
- Change the path in the macros to what you need
- Macros and excel file currently configured for trains - just change the column headings for dat parameters for other object types
- only simutrans standard parameters in Excel file so far but easily changeable

Read_dat macro:
- Reads all dats in a folder
- checks for dat entries beginning with the column headings and extracts that information into the spreadsheet

Write_dat macro
- Writes new dat files in output\ subfolder
- Writes out info from spreadsheet
- Copies across any constraints, images and comments from original dat file

Hopefully this will speed up balancing as I can tweak calculation parameters for costs and accelerations of large number of locos and then batch them out with minimum fuss...
Title: Re: Dat file to spreadsheet reader/writer
Post by: jamespetts on January 18, 2016, 09:10:56 PM
Very interesting! How easy is it to add parameters to this so that this can be used with Experimental?
Title: Re: Dat file to spreadsheet reader/writer
Post by: The Hood on January 18, 2016, 10:55:18 PM
Like typing in a box in Excel easy? Depends how many - the for loop can handle as far as column 30 at present but easily fixed.
Title: Re: Dat file to spreadsheet reader/writer
Post by: Iluvalar on January 19, 2016, 08:30:21 PM
Quote from: The Hood on January 18, 2016, 08:43:29 PM
Hopefully this will speed up balancing as I can tweak calculation parameters for costs and accelerations of large number of locos and then batch them out with minimum fuss...
I have a php script here that can apply a formula to all .dat at once. If you need it for something.
Title: Re: Dat file to spreadsheet reader/writer
Post by: Ves on January 23, 2016, 11:27:50 AM
Wow that was an excelent tool you created there! Just tested it and after the initial pathfinding it nicely loaded, even added some special experimental features (I just tried briefly).
However, I have troubble when clicking on "write_dat". There commes this sign which tells me (in swedish strange enough) that it cannot find the path. Pressing troubbleshoot takes me to a line looking like this: Open OutFile For Output As #OutFileNum in the section of 'Write out data from Excel File.

What am I doing wrong?

edit: never mind, I forgot to manually create the output folder! Maybe a slight suggestion: Let the path specified in the write_dat be the actual path. It might not be obvious for a user that (s)he must create the "output"-folder inside the manually specified folder.
Thanks anyway :)
Title: Re: Dat file to spreadsheet reader/writer
Post by: The Hood on January 23, 2016, 04:37:28 PM
Thanks - it was by no means intended as a fully tested tool - I guess you need a bit of VB knowledge to make sense of it for your own system at the minute. I've barely used it myself yet so I'm sure I will adapt it over time. But anyone is free to adapt the basics of it if they wish. I'll add any updates to this thread if there are any.
Title: Re: Dat file to spreadsheet reader/writer
Post by: Ves on January 23, 2016, 06:19:16 PM
I have originally no VB knowledge, but I managed to adopt all the vehicle parameters for experimental by writing them in the excell and in the macro raise the "for 30" to "for 100" as well as making the tool copy the "livery
Title: Re: Dat file to spreadsheet reader/writer
Post by: vzrenggamani on February 17, 2016, 11:17:38 AM
I have re code some of your files.. like adding read macro button and write button.. anf i have make welcome dialog box .
the question is may i distribute your file i have remaked ? i have write your forum username :)
Regards and thanks
Title: Re: Dat file to spreadsheet reader/writer
Post by: Milko on February 17, 2016, 01:57:33 PM
Hello

Sometimes ago I made a similar tool.

http://forum.simutrans.com/index.php?topic=13094.msg130228#msg130228

My tool offer also a "log", in the log all commands are labeled as valid or invalid. It's useful to chek errors in the dat file.

The macro recurse subdirs.

I have a new version, that show a graph, all vehicles and date introductionand retirement. I will post my new macro.

Giuseppe
Title: Re: Dat file to spreadsheet reader/writer
Post by: The Hood on February 18, 2016, 08:15:37 PM
Quote from: vzrenggamani on February 17, 2016, 11:17:38 AM
I have re code some of your files.. like adding read macro button and write button.. anf i have make welcome dialog box .
the question is may i distribute your file i have remaked ? i have write your forum username :)
Regards and thanks

Sure. Anything I produce and post here anyone can use, modify or distribute but all I ask is that I get credited and that nobody uses my stuff to make a profit for themselves. Not sure what license that equates to legally but that's the deal. Have you uploaded your version somewhere? It would be good to see what you did with it.
Title: Re: Dat file to spreadsheet reader/writer
Post by: An_dz on February 18, 2016, 09:22:43 PM
I guess that's the MIT license.
Title: Re: Dat file to spreadsheet reader/writer
Post by: vzrenggamani on February 18, 2016, 10:51:58 PM
@The Hood : I havent upload it. i will give it to you first before i distribute publicy..