Load/save game attributes to spreadsheet

Hi all!

The question:

Anyone have any idea on how I would export game attributes to a spreadsheet, ideally .ODS? I’ve watched Gavin’s videos a few times, and he is exporting to .txt just fine. I’m wanting the same thing but spreadsheet. Not to the point where I need it yet, so non-emergency status, but looking to figure it out in the next couple months if possible. Reference - https://www.youtube.com/watch?v=vergWzLFn-s

The application:

Using BGE to create an online customization order form for a small business. We’ve currently got 10 (main) products, which each have approximately 20-50 individual pieces that can in turn be one of 20 color options per piece, so lots of data points. The long term goal is to automate everything from the customer to a specific manufacturing point before getting humans involved, and the spreadsheet factor will be a hinge point. I’m confident I could do a spreadsheet that references a .txt, but would like to streamline where possible. Anywho, that’s getting a little too off topic here.

The person background (me):

I’ve heard some people like this background bit just as a reference. Been diddling off and on with Blender for about a year, never had a drive to figure it out until now. Can stumble my way through most things with some strong Google-Fu. Starting the very, very, very, very basics of Python, looking to get a basic level of competency by the end of the year.

Lastly: I’ve got a separate .blend going with my actual models and whatnot, but that has some CAD stuff in it for reference that I can’t just throw out to the internet, so I’ve attached my “figure stuff out” .blend that I use for figuring out how to make stuff work. It’s a little messy, but I had a tough time finding instructions on some of this so I figured I’d put it up and pass it on for anyone in my position.


Attachments

basics test.blend (944 KB)

I suggest to look for some Python libraries that handle the format you want.

You could take a look at this:

It’s a wrapper library that basically links python to .ods. Since you already have the resources to write a .txt file (for save features),
using this library in combination with the bge shouldn’t be too difficult with enough practice (e.g. globalDict -> .txt). I also have my own experience writing save game features using the bge, so I know what it’s like.

More options:

A simple, cross-application solution that is bundled with the stdlib is the ‘csv’ module.
As an aside, this doesn’t seem like the best application for the BGE (or any game engine). Is there a reason for using it?


from csv import DictWriter
from pathlib import Path


field_names = "score", "name" # ...
rows = (
    {'score': 100, 'name': "Guido"},
    {'score': 15, 'name': "Raymond"},
)




file_path = Path("test.csv")
print(file_path)


with open(file_path, 'w', newline='') as f:
    csv = DictWriter(f, field_names)
    
    csv.writeheader()
    csv.writerows(rows)



My heroes :p!

Mirror - That is likely exactly what I need. For some reason I didn’t even think to start looking at the opposite end (.ODS>Python>Blender) and couldn’t find anything for Blender>Python>.ODS

Goose - Honestly yea, it probably isn’t the best application for Blender. It is however: Free (most importantly), skill building, motivating, and an enjoyable challenge. The trick is that I need the 3D interface, ability to control movement of the model, and real time changeable options (colors and a few other things). Blender is something that I know can do these things, runs on Ubuntu, within my ability to learn (tired of paying/waiting on other people), and has an enormous amount of support. All this combined makes it right for me, though maybe not the best thing overall.

Thanks again! I’ll try to remember to bring this thread back from the dead in a month or so when I’ve got the front end stuff up and running.