LuaCSV [Export data from LUA to Excel]

Ok this is a first version of the Excel exporter that I promised.

I mostly wrote it for myself but it’s also meant for people who run competitions and want to copy the values to Excel, as proposed in this thread. It currently only works with the (non Steam) Launcher version 1418. I will make it work for the current version once that is available to non Steam users. However even if you have updated to Steam it will be very handy to see an overview of your past designs. Of course I assume everyone made a backup of their designs, otherwise you’re screwed :slight_smile:

It currently extracts the following values:
Cars: Model Name Year Weight Configuration Cylinders Displacement Peak Power Torque Rpm Top Speed
Engines: Model Name Year Aspiration Configuration Cylinders Bore Stroke Displacement Peak Power Torque Rpm Weight Compression CamProfile Mixture* IgnitionTiming Compressor Turbine ARR Ratio Boost
*it currently cannot export fuel mixture because I did not find it

THE PROGRAM IS DISTRIBUTED “AS IS”. NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE AT YOUR OWN RISK. IN NO CASE WILL THE AUTHOR OR THE AGENTS OF THE AUTHOR BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE
yadda blabla etc. You can do with the program and source code whatever you want, but at our own risk and responsibility.

Here is the sourcecode (C#) global-explorer.de/LuaCSV/Program.cs
It links to LuaInterface which can be downloaded here luaforge.net/projects/luainterface/

The program presumes that you put your models (cars) into the “Models” subfolder. Likewise engines go into the “Engines” subfolder. All required folders and files are already there, you only need to copy YOUR cars and engines to the appropriate subfolderr.
Run the program LuaCSV.exe . It is rather slow so it will take several seconds, that’s normal.
If the program says OK, the results of the export will have been written into “models.txt” and “engines.txt”
Now open those files with a text editor and copy everything ( CTRL-A then CTRL-C )
paste everything into Excel CTRL-V ]. I provided two Excel files with the correct column headers for models and engines accordingly
You should know what you can do from there
And dont forget, if you want rows and columns exchanged, you can simply transpose the tables




Rather than post the code here, would you mind uploading it to github? Might be less heavy on text which inflates the page’s load time.

Also, I assume it’s open source, so you should be able to get it there for free. :slight_smile:

EDIT: I also want to hack around on it. :stuck_out_tongue:

This is actually pretty neat! :slight_smile: When you finish converting it to current build, then it’d be really rather excellent.

[quote=“NexxusDrako”]Rather than post the code here, would you mind uploading it to github? Might be less heavy on text which inflates the page’s load time.

Also, I assume it’s open source, so you should be able to get it there for free. :slight_smile:

EDIT: I also want to hack around on it. :stuck_out_tongue:[/quote]

Ok, I replaced the embedded sourcecode with a simple link so the page is not slowed down. As far as I am concerned the code is free to copy and modify and so you can do all that yourself if you want. No restrictions to authorship etc of my skript, but keep in mind that LUAinterface has its own license (MIT) and is of course not affected by it.

Also if you are really interested you might as well wait until I make a Steam version. Overall everything can be made simpler and faster when I understand the format better.

Sure, but first it must release it to all users.

I see there are still some mistakes in the exported values, engine power and torque seems to to be wrong some times.
will be fixed in time.

I made a pass on the power as I did not understand the numbers at first. The confusion with power was simply that unit was kilowatt and I expected it to be hp. I now convert to horsepower since I’m more used to that. Values seem perfectly ok now.

I also added displacement. Unit is cubic centimeters. If you’re from the US, I am totally not used to square inches. But 1000 cubic centimeters = 1 liter. Not just roughly. But exactly 1000 :slight_smile: So it should not be hard to figure out.

I also made output to .txt instead of csv, so it’s easier to open them if you have file attachments.

Sorry to potentially drag this off topic, but what is this magical LuaInterface library, is there one for C++ and how hard is it to install?

I didn’t even consider looking for libraries which let C++ read lua tables because of the horror show that was manually compiling and installing the OpenCV libraries in a way that would work with visual studios. When I tried doing something vaguely similar to this last year I was trying to read and alter automation’s engine files by reading the lua file as a text file, extracting the relevant parts by searching for specific text strings, then rewriting the entire file again with any modifications needed which, as you can imagine, was horrible

This Luainterface is for .NET (there is a link provided) there should be one for Cpp too, I am sure. I use C# because installing dlls in a project is a breeze. Usage is a bit tricky because the functions return type object and you must figure out wether you can cast it to which type. Hence the repetitive boilerplate and occasional stupid casts like (int)(double). Now that I have done it once I think I can make it much simpler by writing my own parse(*type) routines, and making a much leaner script, instead of doing it over and over.
I thought about parsing text too but that would become extremely awkward. Not recommended.
It’s currently still a mess because the values are strewn over different tables, therefore I often parse for the max value. Not perfect, but it works.

when are you expexting to update it so its steam compatible

You must ask Camshaft Software when they make it available to existing customers, not me.

And for 'mericans out there: 1 CID = 16.387 cc and 1 cc = 0.061 CID

To save people the hassle of copy/pasting things from a text file to an excel file, have you considered exporting the results into a .csv file? That way excel could open it straight away, albeit without any font formatting. I know there’s a way of exporting directly to a proper excel file, but I did that several years ago and cant remember how :stuck_out_tongue:

Actually, it is creating a csv file from the beginning. The text output is already a csv file with tabs as separators, but its a pain in the rear to use that route.
Importing it as a CSV file is actually creating more hassle than the 2 simple copy paste steps described (CTRL-A, CTRL-C, CTRL-V). Believe me, I created it for myself most of all, and I use Excel extensively, so why would I make it harder on myself.

Best way to export it to a proper Excel file would be with a VBA script made in Excel.

But, as you said, you can just open the CSV with Excel and then save it as an Excel file.

[quote=“BurningBridges”]Actually, it is creating a csv file from the beginning. The text output is already a csv file with tabs as separators, but its a pain in the rear to use that route.
Importing it as a CSV file is actually creating more hassle than the 2 simple copy paste steps described (CTRL-A, CTRL-C, CTRL-V). Believe me, I created it for myself most of all, and I use Excel extensively, so why would I make it harder on myself.[/quote]

Fair enough. I just thought it might make things slightly easier for incredibly lazy people like me :stuck_out_tongue:

[quote=“trackpaduser”]Best way to export it to a proper Excel file would be with a VBA script made in Excel.

But, as you said, you can just open the CSV with Excel and then save it as an Excel file.[/quote]

Of course I could also write it directly to Excel file, but that means you must have Excel installed. But that’s a whole lot of effort for a little skript that you only run a few times ever. Shouldnt be too hard to follow the instructions and just copy the stuff.

It won’t run on my laptop. Could you list the requirements for this to work?

I have Win7 x64 with .NET 4.5.1 (and .NET 3.5) installed. Anything more specific?

Here was my error. “LuaCSV” is extracted to “My Documents” folder, if that is of any significance.

[code]Description:
Stopped working

Problem signature:
Problem Event Name: APPCRASH
Application Name: LuaCSV.exe
Application Version: 1.0.0.0
Application Timestamp: 55049e6c
Fault Module Name: KERNELBASE.dll
Fault Module Version: 6.1.7601.18409
Fault Module Timestamp: 5315a05a
Exception Code: e0434f4d
Exception Offset: 000000000000940d
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1033

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\windows\system32\en-US\erofflps.txt
[/code]

The only requirement is dotNEt 2.0 but it should work with your version. I think the problem is rather the LuaInterface.dll, wouldnt be surprised if its not 64 bit compatible (release date is 2004?).
Which reminds me I dont even know if I used the latest version :slight_smile:
next time I will read about the topic, for now, you could just upload your models/engines as a zip and someone else will convert them to Excel, I mean someone with a red car in his signature :slight_smile: (its barely 2 minutes work)

Yes, that seems to be the issue. LuaInterface.dll and Lua51.dll are 32-bit only. They would have to be recompiled and re-referenced for a 64-bit environment. There were some alternatives listed. NuLua is supposed to be the easiest one to use for this purpose. Maybe I will try it this weekend, but I don’t know a thing about C#. It is different from C++ (which I do know) and more like Python, or so I have heard.

Ok that’s it then.
It shouldn’t be hard for you to do in C#. Copy the dlls to your VS project and add it via references. Just choose “browse to file” and include the namespace. You can also see in my sourcecode how I used the rather strange Lua class. There are probably better, and certainly faster ways but I am a beginner how to do use it. The return value is always undetermined, so I need to check types and cast a lot.