Load CSV file from local drive into DataTable for Cesium

Hello, I have followed the tutorial from Cesium concerning a flight tracker (Build a Flight Tracker with Cesium for Unreal – Cesium) and they import the CSV there as a DataTable . I was wondering: how can I load any CSV file from my local Windows drive into the game as a DataTable , at runtime (so when playing the game). I would like to go to the result where the player imports a CSV from his/her local drive into the game at the start, and then the flight starts. Does someone has experience with this?

1 Like

There are plugins that can do it.
Or you can do it in c++,. code is simple and standard stuff. Maybe there are ready snippets to do it.
And i think (but i am not sure) that unreal c++ has already CSV code, all you need to do it declare blueprintable functions for it and compile.

1 Like

I read about the Victory Plugin that could do it, but how is a mystery. Concerning C++: I’m happy to use that, but I have not found any snippits and/or tutorials on how to do this properly.

For C++ you need to load whole CSV into memory, then parse it.
Loading to memory is just C++ to read file.
Then you need to parseit with code like this:

Or if CSV is simple you can make blueprints for it.

ps.
You can also convert csv to json, and there is some support for json in unreal.

1 Like

Hello. I was able to write some C++ code that works:

Which allows me to load it as an array:

Now I need to find out how to switch from the DataTable to the array.

1 Like

Try this stuff, instead of making TArray:

UDataTable* RuntimeTable = NewObject<UDataTable>();
RuntimeTable->RowStruct = FMyRowStruct::StaticStruct();

FMyRowStruct NewRow;
NewRow.SomeValue = 42;

RuntimeTable->AddRow(FName("Row1"), (uint8*)&NewRow);

So you get actual table.

Or even better make second function that produces data table out of your array.
Then if both exposed to blueprints you just chain them to get table

Thanks for the addition. The only reason for me to do that (going from an array to a DataTable) is when I find out how I can set the chosen file as a DataTable in the PlaneTrack from the tutorial: Build a Flight Tracker with Cesium for Unreal – Cesium .

In Unreal Engine, it looks like this:

Here I choose in UE the CSV, but I want to go to a situation where I can choose it at runtime. That is the part that I haven’t figured out yet.