Skip to main content
ouchs29
Participant
May 14, 2023
Question

Increment number in expression to get data from CSV

  • May 14, 2023
  • 1 reply
  • 254 views

Hello everyone, 
I am trying to duplicate comp and have the after effect expression to pull the data from CSV file according to the comp index. Im currently getting error and wondering if someone can help me out on this. 

Heres my code: 

 

var compIndex = parseInt(thisComp.index);
var dataValue = footage("data.csv").dataValue([compIndex - 1, 5]);

dataValue;

If comp index is 1, then the location of the data for comp 1 is [0, 5];

Then when I duplicate this comp, then the comp index will be 2, and it will pull data from [1, 5] in the csv file;


Hope this make sense. Appreciate the help!

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
May 14, 2023

Comps don't have an index. Maybe you could parse a number at the end of the comp's name, so this:

parseInt(thisComp.name.split(" ")[1])

would give you 3 for a comp named "Comp 3"