Anything is possible I haven’t dealt with CSV in Godot but it would certainly be possible to write a parser that gives you dictionary objects.
You might want to reconsider CSV for your database, there are some cool tools that can output JSON in a way that is much easier to parse in Godot eg. CastleDB - take a look at this video https://www.youtube.com/watch?v=TdWWiVd1IxQ
Looks like a great tool, I just looked it up, but I still wanted to use CSV because I already had a data structure to use and I didn’t wanted to change it :>, I eventually got it to work, I post it as an answer.
The_Black_Chess_King | 2020-05-21 17:18
I am looking into that particular situation myself and I tried CastleDB. It does make the exporting into JSON easy but it lacks very important feature, like sorting columns, filtering, searching, editing multiple values at the same time, etc. A modern spreadsheet editor has much better tools for that. The nice thing about CastleDB is that is links data between tables, so I still have no good solution for creating, tweaking, balancing my big database.
While yea JSON has some advantages like faster parsing, I liked the way I could design a compiling structure from my raw string data imported from CSV files, so far I have not had any problems with perfomance, so I sticking with it.
I needed a lot of data organized and the way I have done was through .CSV files, in the end everything worked as expected, however, later I runned into some minor issues.
→ When exporting the game, no .csv files were exported and the console would loop with errors like “Needs to be open before use”, the problem was that I couldn’t include .csv files format in the exported game in any way shape or form. The workaround was simply to rename them to .tres, which makes godot export them automatically, and I still could open them with spreadsheet programs.
→ When editing the files, the program that I used was locking them, and Godot couldn’t run the game, which made a pain for testing the game, as I had to change the values that I needed, close the program, them test on Godot, open the spreadsheet later, edit, repeat. The solution was to duplicate the data folder outside of the project and run with a thirdparty program a simple folder sync to the godot project folder, so I could edit multiple data files, press a sync button, and test the game without worrying about closing the program.
Eventually you only need 1 single file for all data, you can discriminate multiple structures in 1 file. For example, you could just put a special character in the csv files that when compiling in Godot make it ignore the spreadsheat field if it contained that character. Something similar like my code but better imo:
if !LINECSV.has("#") and LINECSV != DATA_CSV.size()-1: #Compile data
This will make you able to split multiple data structures in one file, you could do say:
var WEAPON_ID = DATA_CSV[LINECSV] #Because it has WEAPON_ as prefix, the compile structure here can consider it as a weapon, you could do that with NPC_Data, MAP_Data, STAT_Data, SKILL_Data, or anything you want.
The key with compiling methods from the csv files was the string built-in functions in Godot, for example, I could split a string everytime it encoutered a ‘/’ , and creates a array from that, or I could split between two numbers by ‘:’ and consider them a vector2, then in my spreadsheet I could write values like: [32:64] and godot would read as Vector2(32,64).
It’s really powerful what you can do with simple values in a spreadsheet, I seriously hope they implement in Godot a way to edit csv files directly, it’s too dam powerful, we can make use of databanks for any purpose we want, and some games cannot be developed without them.
The_Black_Chess_King | 2021-01-31 13:33