Copy link to clipboard
Copied
Hi there,
I'm going crazy triing to write an expression for visualize different value over time using a CSV. I've got 2 colums, the first has a frame timestamp, the second one the value that I need to visualise. The problem is that the timestamp isn't updated with a constant interval, so I'm triing to write an expression that look at the value of the first column and if this value is equal to the comp time in frame it update the visualised value taken from the second column.
Here my expression so far, I'm pretty sure that I'm missing something:
var thisFrame = timeToFrames(time);
var i = 0;
if (i == dataFrame){
i + 1
var dataFrame = footage("Scenario 4 dataset Frames + Load.csv").dataValue([0,i])}
footage("Scenario 4 dataset Frames + Load.csv").dataValue([1,dataframe])
I also attach a screenshot of the csv file.
Thanks to who'll try to help me!
1 Correct answer
If you drag your csv file onto your timeline, you can do something like this:
f = timeToFrames(time);
L = thisComp.layer("Scenario 4 dataset Frames + Load.csv");
numRows = L("Data")("Number of Rows");
frames = L("Data")("Outline")("Frames");
load = L("Data")("Outline")("Load (Kg)");
for (i = 1; i <= numRows; i++){
if (f < frames(i)){
break;
}
}
i--;
i < 1 ? "???" : load(i)
Copy link to clipboard
Copied
If you drag your csv file onto your timeline, you can do something like this:
f = timeToFrames(time);
L = thisComp.layer("Scenario 4 dataset Frames + Load.csv");
numRows = L("Data")("Number of Rows");
frames = L("Data")("Outline")("Frames");
load = L("Data")("Outline")("Load (Kg)");
for (i = 1; i <= numRows; i++){
if (f < frames(i)){
break;
}
}
i--;
i < 1 ? "???" : load(i)
Copy link to clipboard
Copied
Dan Thank you so much! That's exacly what I was looking for! If is not a problem, can I ask you to explain how does the "for" loop work? I'd like to better understand coding.
Thanks again!
Copy link to clipboard
Copied
The for loop iterates through the Frames column until it finds a value that is greater than the current frame number. It then exits the loop, subtracts 1 from the counter index "i" and uses that index to get the corresponding Load (Kg) value.

