Skip to main content
New Participant
October 22, 2022
해결됨

Compare csv time data to update another csv parameter

  • October 22, 2022
  • 1 답변
  • 517 조회

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!

 

 

이 주제는 답변이 닫혔습니다.
최고의 답변: Dan Ebberts

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)

 

1 답변

Dan Ebberts
Community Expert
October 22, 2022

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)

 

MattiaG작성자
New Participant
October 23, 2022

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!

 

Dan Ebberts
Community Expert
October 23, 2022

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.