Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Accessing first row of external csv via the 'footage' object?

  • Accessing first row of external csv via the 'footage' object?

    Posted by PJ Palomaki on February 21, 2022 at 11:00 am

    Hi, I’m using footage.dataValue() to dynamically change all text in my project using expressions in text layers. The source of the text is a CSV file with language names (i.e. ‘English’ ‘French’ etc) in the first row and then each row after that includes a string of text for each AE text layer. So each column is a different language translation.

    I can access the CSV fine and adjust all the text to correct languages, but one thing I just can’t figure out – is how to access the very first row of the CSV, which in my case is the language names.

    I don’t want to include the csv into the comp as the file name will change multiple times and I’m using a utility comp to define the file name to use. So my option is to use footage.dataValue(), more specifically:

    footage(comp(“Utility”).layer(“Filename”).text.sourceText).dataValue([0,0]);

    But unfortunately, that value gives me the 2nd line of the CSV file, not the first. If I include the CSV into the comp, I can access the first row with this:

    thisComp.layer(“TXT Translation doc CT_v2 TEST.csv”)(“Data”)(“Outline”)([1])

    But this means every time the file is changed, I would either have to replace the existing in the project panel, or change it in the comp.

    Is there any way to access the first row of an external csv, using the footage object?

    PJ Palomaki replied 4 years, 5 months ago 2 Members · 9 Replies
  • 9 Replies
  • Filip Vandueren

    February 21, 2022 at 1:18 pm

    I have the habit of splitting and parsing csv’s myself.

    If things get more complicated, I use a javascript library like babyparse/papaparse which you can easily embedded into an after effects expression, but you can do it naively if you’re sure there are no extra comma’s or linebreaks etc. in any stringvalues, like this:

    footage("data.csv").sourceText.split("\r")[0].split(/,/);

    this will give you an array of everything that was on the first line of text, split by comma’s.

  • PJ Palomaki

    February 21, 2022 at 2:55 pm

    Excellent, thank you!

  • PJ Palomaki

    February 21, 2022 at 5:27 pm

    On a separate topic, is there a way to ‘freeze’ text layers so that the expression is not calculated on every frame?

  • Filip Vandueren

    February 21, 2022 at 6:24 pm

    Yes; start your expression with the line:

    posterizeTime(0);

    It doesn’t prevent the property/expression from recalculating when something changes in the comp while working, but it does only calculate once when you render or ram preview

  • PJ Palomaki

    February 24, 2022 at 12:07 pm

    Excellent, thank you.

    And another follow-up question:

    Using this method (footage.dataValue()), is there any way to add in-line formatting in the CSV which would carry over to the AE text layer? For instance:

    Welcome to the show end of first line \n\ this is second line.

    Sometimes a word or words of a complete line needs to be highlighted (bold, italics, color etc) and I’d like to do that without breaking the line into three, and then formatting the middle line in AE, as this process is potentially a huge headache for translations.

  • Filip Vandueren

    February 24, 2022 at 3:28 pm

    There is no way to style a section of your text using expressions.

    The only work arounds are using text animators that control the stroke width of a range of characters (emulating faux bold, but without the increased tracking) or provide a slant to some characters (faux italic/oblique)

    How would the expression know what word to highlight ? Does it use RTF ? or HTML tags ?

  • PJ Palomaki

    February 24, 2022 at 4:13 pm

    It could use RTF or HTML or anything really, just wondered if you’ve come across a way to force AE to render certain part of the text source differently. I wonder how it stores that data internally and if there’s a way to hook to that.. I know that you can style part of a text layer differently using AE’s built-in tools.

  • Filip Vandueren

    February 24, 2022 at 4:25 pm

    Like I said, expressions nor scripting can alter the styling of parts of a text-layer. You can only style the entire layer, not a word or selection within it.

    There exist solutions of marking a [part of your text] with characters like those square brackets, then hide them but use their indexes to create animation ranges, which can do limited things like change the color, add a stroke, slant,… but not actually change font properties like in the character styling.

    It’s a question that gets asked quite often on the forum, unfortunately the search seems broken now, so I can’t point you to a solution right now.

  • PJ Palomaki

    February 24, 2022 at 4:37 pm

    Ok thanks for your help, I’ve got a good enough solution now to use the workflow in our project so all good!

    Thanks again.

    -PJ

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy