Activity › Forums › Adobe After Effects Expressions › count from 0 to a number from a csv file
-
count from 0 to a number from a csv file
Posted by Obed Ampong on September 19, 2018 at 5:18 pmHi,
I am trying to count from 0 to a number from a csv file.
I tried this expression below but it does not count. Please is there any way out?
Thanks in advance
Regards
ObedstartCount = 0;endCount = idx = parseInt(thisComp.name.match(/\d+/),10)-1;
footage("cities.csv").dataValue([idx,2]);countDur = 4;
Math.round(linear(time,0,countDur,startCount,endCount))
Obed Ampong replied 7 years, 10 months ago 2 Members · 15 Replies -
15 Replies
-
Dan Ebberts
September 19, 2018 at 5:37 pmIt’s not clear what your comp name looks like, or what’s in your data file, but it doesn’t look like you’re doing anything with the CSV data. Maybe your endCount should be set to the value from the CSV file?
Dan
-
Obed Ampong
September 19, 2018 at 5:46 pmThanks, Dan for the reply, I am trying to set the value to the data on the csv data. At the same time, I want the value to change automatically when I duplicate the entire comp.
-
Dan Ebberts
September 19, 2018 at 5:50 pm>I am trying to set the value to the data on the csv data.
The way you have it set up, this line:
footage(“cities.csv”).dataValue([idx,2]);
doesn’t do anything. I don’t have any way to test it, but I’m guessing maybe this is what you want:
startCount = 0;idx = parseInt(thisComp.name.match(/\d+/),10)-1;
endCount = footage("cities.csv").dataValue([idx,2]);countDur = 4;
Math.round(linear(time,0,countDur,startCount,endCount))
Dan
-
Obed Ampong
September 20, 2018 at 11:38 amHello Dan,
Please, I have one issue. I would like the expression to refer to the layer time instead of the comp time so that I can offset the layer to any time and the expression will begin at that time. Could you kindly help me out?
Thanks in advance.Regards,
ObedstartCount = 0;idx = parseInt(thisComp.name.match(/\d+/),10)-1;
endCount = footage("cities.csv").dataValue([idx,2]);countDur = 2;
var num = Math.round(linear(time,0,countDur,startCount,endCount))
num = Comma(num);
[num]function Comma(number)
{
number = '' + Math.round(number);
if (number.length > 3)
{
var mod = number.length % 3;
var output = (mod > 0 ? (number.substring(0,mod)) : '');
for (i=0 ; i < Math.floor(number.length / 3); i++)
{
if ((mod == 0) && (i == 0))
output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
else
output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
return (output);
}
else return number;
}
-
Dan Ebberts
September 20, 2018 at 1:05 pmTry changing this line:
var num = Math.round(linear(time,0,countDur,startCount,endCount))
to this:
t = time – inPoint;
var num = Math.round(linear(t,0,countDur,startCount,endCount));Dan
-
Obed Ampong
October 4, 2018 at 10:54 amHi Dan,
Please, I changed the CSV file and After Effects says there is an error in line 4. Could you kindly help me out?
Thanks always.Regards,
ObedstartCount = 0;idx = parseInt(thisComp.name.match(/\d+/),10)-1;
endCount = footage("COMPANIES.csv").dataValue([idx,4);countDur = 3;
t = time - inPoint;
var num = Math.round(linear(t,0,countDur,startCount,endCount));num = Comma(num);
[num]function Comma(number)
{
number = '' + Math.round(number);
if (number.length > 3)
{
var mod = number.length % 3;
var output = (mod > 0 ? (number.substring(0,mod)) : '');
for (i=0 ; i < Math.floor(number.length / 3); i++)
{
if ((mod == 0) && (i == 0))
output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
else
output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
return (output);
}
else return number;
} -
Obed Ampong
October 4, 2018 at 3:33 pmIt has 7 rows and 50 columns. I made it with excel just like the first one
Reply to this Discussion! Login or Sign Up