News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Dat file to spreadsheet reader/writer

Started by The Hood, January 18, 2016, 08:43:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

The Hood

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...

jamespetts

Very interesting! How easy is it to add parameters to this so that this can be used with Experimental?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

The Hood

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.

Iluvalar

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.

Ves

#4
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 :)

The Hood

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.

Ves

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
  • =" and way constraints like it originally copied the "emptyimage".
    However, I get the same error again (after altering the number of obj from 7 to 50) but it appears to copy perfectly. Any idea why the error (about not finding its path) occurs?

vzrenggamani

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

SIMUTRANS INDONESIA WEBSITE  <<< Indonesia Simutrans Addons Center And Web
HOPE YOU UNDERSTAND MY ENGLISH

Milko

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

The Hood

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.

An_dz


vzrenggamani

@The Hood : I havent upload it. i will give it to you first before i distribute publicy..

SIMUTRANS INDONESIA WEBSITE  <<< Indonesia Simutrans Addons Center And Web
HOPE YOU UNDERSTAND MY ENGLISH