First of, I am a relative novice with Unreal, using it on and off.
So I have some knowledge but not much
I have a project for which I get data from a data table for temperature in the year 1938.
I want to retrieve temperature data according to today’s date.
Ultimately, I want to subtract temperature data from 1938 archive to today’s temperature data, in order to generate a variable.
This is the idea :
If (‘Date_1938_from_data_table’ = ‘today_date’) {
then output corresponding row for ‘Temp_Hamamatsu’
}
For exemple :
if (‘1 mar (1938)’ = ‘1 mar (20XX)’) {
then output 8.5
}
I guess the idea is to loop through the data table and find corresponding string.
Although, I am simply stuck at processing this.
Also considering I had like unreal ‘as date’ function to only output day/month, as the idea is compare dates as strings for any year – basically to compare 1938_date to 2023_date, 2024_date, 2025_date, …).
Use the actual date format you want to use - they’re unique. This way you do not need to loop anything. You can just look it up - which is orders of magnitude faster, and more convenient.
You could even use the date time struct format for this:
But you probably do not needs hours, seconds, etc… So use a format you need. Once you have rows named the way you need you can look them up instantaneously by parsing data to the desired format:
Also considering I had like unreal ‘as date’ function to only output day/month, as the idea is compare dates as strings for any year – basically to compare 1938_date to 2023_date, 2024_date, 2025_date, …).
Using Date Time could work well here - the nodes above, on the right are actually subtraction nodes.
I indeed have a format problem that I have to correct from the spreadsheet - btw the integers in the first column are due to an import bug when I save the spreadsheet as a CVS from open office, without this extra column the CVS wouldn’t import properly in UE.
But I do not understand how (the first part of your answer) allows to automatically find the date of the day (today) and output the temperature data that corresponds to its row?
What I want to do is really this:
If (‘Date_1938_from_data_table’ = ‘today_date’) {
then output corresponding row for ‘Temp_Hamamatsu’
}
For exemple :
if (‘1 mar (1938)’ = ‘1 mar (20XX)’) {
then output 8.5
}
The idea is to have a system that updates automatically everyday.
Everyday, the corresponding date is found and the associated temperature is outputed.
(Then, I do the substraction between the 1938_temperature and today_temperature. But I figured this operation already.)
What I don’t get, is how to get the data I want from the data table everyday?
That is why in my screenshot I used the function ‘Now’ and ‘As date’ to output a string for today.
Then, the idea is to find the corresponding string within the table data and output the corresponding temperature.
So I understand that the date format from my CVS and Unreal date format have to be the same.
I just don’t know if that is the right way to do and also how to do it properly.
A far as I understand your answer doesn’t take in account this everyday-update aspect? or am I missing (likely) something?
Sorry, it took me some times to understand the function of the different nodes and to adapt your answer to my need.
Although, thank you, I managed to make it work.
Only, I have one last question.
As I said in a previous message, I experience issue when important a .cvs in Unreal.
Unreal fails to detect the first row (in that case ‘date’)
Thus, UE creates one automatically, thus, displacing the data of the first column ‘date’ into the automatically created one.
It doesn’t affect the workflow here, but it isn’t the most elegant.
Do you have any idea where it can be coming from?
Does your *.csv have a column named exactly like this? Can you show the upper left corner of the spreadsheet? Essentially, this needs to be empty:
The struct’s elements we use to represent the data must match exactly what’s in the file.
One good trick to pre-format stuff perfectly is to export a data table.
This way you’ll get a file with perfectly formatted columns, you can then use it a base for something else. Super handy if we need to pull some complex data. And for nested structures or arrays of data, I’d suggest switching to json sooner rather than later.
Unreal simply keeps on telling the first column (date) doesn’t exist and then replaces it with the automatic ‘Row Name’… and strangely displaces the ‘date’.
What’s even weirder is that as you can see on the image, in the row editor, I can modify data in the ‘Date’ row… but not in the added ‘row name’ one.
Anyway, it works out, it’s more for sake of esthetic at this point.
I tried to export the data table as a .cvs but reimporting this version in OpenOffice makes it unworkable.
I believe there is perhaps a little issue on exporting a .cvs from OpenOffice as the first row isn’t detected by Unreal.