Skip to main content
Participant
March 9, 2020
Question

Number of lines in CSV file?

  • March 9, 2020
  • 1 reply
  • 523 views

I import a simple CSV file with a list of words from my project panel:

 

words = footage("words.csv");

 

I loop through this array by manually setting the number of lines. Every time I add a word to the list I have to adjust this number though. How can I retrieve the number of lines with an expression? Obviously, the expression

 

words.length

 

doesn't work.  

    This topic has been closed for replies.

    1 reply

    Mylenium
    Legend
    March 9, 2020

    You have to write your own for() loop with string processing/ a regular expression looking for the line break/ carriage return and then stop at the EOF or the last line that doesn't have a CR. There is no pre-defined function for any of this in JavaScript.

     

    Mylenium

    Participant
    March 9, 2020

    Thank you! I found an easier solution: I put all the words on one line separated by spaces. In After Effects I split this long string by spaces and get a regular array with a defined length.