The International Simutrans Forum

 

Author Topic: Dat file to spreadsheet reader/writer  (Read 4442 times)

0 Members and 1 Guest are viewing this topic.

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Dat file to spreadsheet reader/writer
« 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...

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Dat file to spreadsheet reader/writer
« Reply #1 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?

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Dat file to spreadsheet reader/writer
« Reply #2 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.

Offline Iluvalar

  • *
  • Posts: 136
Re: Dat file to spreadsheet reader/writer
« Reply #3 on: January 19, 2016, 08:30:21 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.

Online Ves

  • Devotee
  • *
  • Posts: 1675
  • Languages: EN, SV, DK
Re: Dat file to spreadsheet reader/writer
« Reply #4 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 :)
« Last Edit: January 23, 2016, 11:41:30 AM by Ves »

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Dat file to spreadsheet reader/writer
« Reply #5 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.

Online Ves

  • Devotee
  • *
  • Posts: 1675
  • Languages: EN, SV, DK
Re: Dat file to spreadsheet reader/writer
« Reply #6 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
  • =" 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?

Offline vzrenggamani

  • *
  • Posts: 86
  • SetanKothak Families :v :v
    • OpenWorld Tech
  • Languages: ID, EN, C++, HTML
Re: Dat file to spreadsheet reader/writer
« Reply #7 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

Offline Milko

  • Devotee
  • *
  • Posts: 829
Re: Dat file to spreadsheet reader/writer
« Reply #8 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

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Dat file to spreadsheet reader/writer
« Reply #9 on: February 18, 2016, 08:15:37 PM »
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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2898
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Dat file to spreadsheet reader/writer
« Reply #10 on: February 18, 2016, 09:22:43 PM »
I guess that's the MIT license.

Offline vzrenggamani

  • *
  • Posts: 86
  • SetanKothak Families :v :v
    • OpenWorld Tech
  • Languages: ID, EN, C++, HTML
Re: Dat file to spreadsheet reader/writer
« Reply #11 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..