• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Compare csv time data to update another csv parameter

Community Beginner ,
Oct 22, 2022 Oct 22, 2022

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!

 

 

TOPICS
Expressions , How to

Views

142

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 22, 2022 Oct 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)

 

Votes

Translate

Translate
Community Expert ,
Oct 22, 2022 Oct 22, 2022

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)

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 23, 2022 Oct 23, 2022

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!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2022 Oct 23, 2022

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines