The International Simutrans Forum

 

Author Topic: [datSheet v1.1.0] Generate dats from spreadsheets (xlsx)  (Read 293 times)

0 Members and 1 Guest are viewing this topic.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2765
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
[datSheet v1.1.0] Generate dats from spreadsheets (xlsx)
« on: May 20, 2018, 03:52:21 AM »
From the discussion about helping pak192.comic I recommended the team to use Microsoft Office Excel Online, you can see the reasons why here at the top of my reply.

So I created a command line tool that generates dat files from a sheet file. It's called datSheet and source is on GitHub.

It's compiled C++ code, so it's fast and you don't need to have Excel, anyone can use it.
It generates dat files for an entire pakset, generating them following the pakset hierarchy.

Currently only xlsx files are supported (LibreOffice Calc can save these). It works with any parameters because it does not make any checks, the basis is that each row in the sheet is a Simutrans object and each column a parameter. You can leave a value blank and that won't be output.

The first column and the first row are special. If there's any value in the first colunm of a row that row is considered a Simutrans object and the tool will generate a dat for that line, this allows you to add other data in the sheet, like comments and global calculations, without problems, just don't add anything to the first column and that row won't output. And for the first row, where the dat parameters are placed, the same thing happens, any column that doesn't have anything in the first row is ignored, this way you can add comments in each object without those being output in the dat files.

Another point is the sheets and their names, a xlsx file can hold multiple sheets and each sheet is considered an hierarchy in the pakset project, their names is the name of the folder where the dat will be generated into. For example, if a sheet is called factories all dats defined in this sheet will be created in a folder with the same name.

For a more detailed explanation you can download the template.xlsx file in the root of the project. It explains everything you might need to know about how to set it up correctly.

Download
You can download compiled versions for Linux and Windows on GitHub
https://github.com/An-dz/datSheet/releases

Call datSheet --help for usage help.
« Last Edit: June 02, 2018, 03:08:46 AM by An_dz »

Online DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2287
  • Languages: EN
Re: [datSheet] Generate dats from spreadsheets (xlsx)
« Reply #1 on: May 20, 2018, 09:59:38 AM »
Quote
It's compiled C++ code, so it's fast
I doubt speed would ever be a problem. To put it in perspective a Java based dat parser can process several thousand records in well under a second, and that includes parsing, export, import and update.

How does one bundle multiple records in a single file? It is common that dependant or related data be distributed in a single dat file so that it can be added/removed in a consistent way. For example in Simutrans Extended Pak128 Britain tenders are often part of the same file as the engines that depend on them if they are only used by 1 engine. Another example is an entire set of coaches might be provided in a single file.

If people need help converting an existing pakset into a spreadsheet I might be able to hack together some Java program to do it.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2765
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [datSheet] Generate dats from spreadsheets (xlsx)
« Reply #2 on: May 20, 2018, 04:54:00 PM »
I doubt speed would ever be a problem. To put it in perspective a Java based dat parser can process several thousand records in well under a second, and that includes parsing, export, import and update.
I was actually comparing with things like a VBA script.

How does one bundle multiple records in a single file?
Yes, this feature is still not available as I could not think of a solution yet.

Offline Matthew

  • *
  • Posts: 97
  • Languages: EN, some ZH, DE & SQ
Re: [datSheet] Generate dats from spreadsheets (xlsx)
« Reply #3 on: May 20, 2018, 07:33:19 PM »
What a wonderful contribution to our community! Thank you, An_dz!

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2765
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [datSheet] Generate dats from spreadsheets (xlsx)
« Reply #4 on: May 25, 2018, 07:35:14 PM »
New version allows to create a single dat for multiple dats, one needs to create a column titled filename and set the same filename for multiple consecutive rows. More info in the template.xlsx file.