Skip to main content
Jøsh994
Known Participant
January 15, 2023
Answered

Can I create expressions that can function similar to keyframes and use CSV data?

  • January 15, 2023
  • 2 replies
  • 1825 views

Hello everyone,

 

I'm currently working on an animated leaderboard in After Effects, and I'm trying to make 2 animations inside of it:

1. For each team, their "line" appears, there is a 1 second pause, and then a point total increases based on points earned today.

2. The "line" then moves up or down on-screen depending on whether the team moved up or down in the standings.

 

To do so, I have a CSV file with frames, pixel measurements, and all the required starting and ending points. However, I do not know how to go about importing the data so that it can be used in an expression.

 

What would the expression look like? Here are the variable names I am using:

- startScore (what was their score yesterday?)

- endScore (what is their new score after today?)

- startPos (what is their line's starting on-screen coordinates? only the Y coordinate is changing, if that matters.)

- endPos (what is their line's ending on-screen coordinates?)

 

I am fairly new to Adobe CC, so I might have to ask for elaboration. Please bear with me.

 

Thanks,

Jøsh994

He/Him/His

This topic has been closed for replies.
Correct answer Dan Ebberts

As an example, you could import your csv file into the project panel, and then have a source text expression like this:

f = footage("CSV Sheet.csv");
i = index -1;
startScore = f.dataValue([0,i]);
endScore = f.dataValue([1,i]);
tStart = 1;
tDur = .5;
linear(time,tStart,tStart+tDur,startScore,endScore).toFixed(0)

 

 

and a position expression like this:

 

f = footage("CSV Sheet.csv");
i = index -1;

startPos = f.dataValue([2,i]);
endPos = f.dataValue([3,i]);

tStart = 1;
tDur = .5;

y = linear(time,tStart,tStart+tDur,startPos,endPos);
[value[0],y]

 

 

 

2 replies

Mylenium
Legend
January 16, 2023

There have been several such questions in the last year or so, so if you do a little digging on the forum you may be able to find some of this stuff. Otherwise indeed some more info would be required such as a sample CSV file.

 

Mylenium 

Jøsh994
Jøsh994Author
Known Participant
January 16, 2023

Hi Mylenium,

 

Here is a copy of my CSV.

Dan Ebberts
Community Expert
Community Expert
January 16, 2023

What does the CSV file look like?

Jøsh994
Jøsh994Author
Known Participant
January 16, 2023

Hi Dan,

 

I have attached here a screenshot where I've put all the CSV values into a spreadsheet. The `Score`s are meant to be text, and the `Pos` are meant to be y-coordinates. I just need to find a way to call them into keyframes.

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
January 16, 2023

As an example, you could import your csv file into the project panel, and then have a source text expression like this:

f = footage("CSV Sheet.csv");
i = index -1;
startScore = f.dataValue([0,i]);
endScore = f.dataValue([1,i]);
tStart = 1;
tDur = .5;
linear(time,tStart,tStart+tDur,startScore,endScore).toFixed(0)

 

 

and a position expression like this:

 

f = footage("CSV Sheet.csv");
i = index -1;

startPos = f.dataValue([2,i]);
endPos = f.dataValue([3,i]);

tStart = 1;
tDur = .5;

y = linear(time,tStart,tStart+tDur,startPos,endPos);
[value[0],y]