ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

$.evalFile (txt, tsv, csv, xml...etc)

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
$.evalFile (txt, tsv, csv, xml...etc)
on Jun 15, 2017 at 9:03:17 am

I've seen this question asked a hundred times, none of which have had any luck, but a lot of the forums are 2 years old.

I'm pulling an RSS feed into excel or google sheets (Both seem to work ok)

I'm doing this a nasty way but it works.

A2 B2 C2
Comp1 = " IMPORTED RSS FEED ";

When I manually export as .txt or .tsv, these can be linked automatically into after effects, which is great using $.evalFile.

I want to automate this completely.

My IT department know how to create the above, but only as a spreadsheet, that so far can't be used instantly without changing it into a text document and altering the text.

Basically, my machine will auto export the After Effects comp when unattended (This we have working), but I need a file format that can be generated automatically that I can have the expression update automatically that isn't a .txt or .tsv, If I can get it to read a .csv that would be great, but I'm having no luck.


Return to posts index

Dan Ebberts
Re: $.evalFile (txt, tsv, csv, xml...etc)
on Jun 15, 2017 at 10:47:40 am

The content of the file needs to be legal JavaScript. I don't see any way around that.

Dan



Return to posts index

Scott McGee
Re: $.evalFile (txt, tsv, csv, xml...etc)
on Jun 15, 2017 at 11:20:42 am

Cheers Dan,

Understandable.

Ok, another route we could do, is have the machine convert the data to .txt

But excel is exporting it like this.


"Text1 = "RSS FEED";"
"Text2 = "RSS FEED";"


If I go in and manually delete the "" at the front and end of each line, this works fine. Otherwise it won't work.

Is there a way to convert this expression to look between "" on each line?

$.evalFile("filepath");
eval("Text1");


Return to posts index


Dan Ebberts
Re: $.evalFile (txt, tsv, csv, xml...etc)
on Jun 15, 2017 at 3:02:06 pm

If you can encase your text file in triple quotes like this:

"""

"""

The you should be able to read it like this:

myText = $.evalFile(myFile);

and all the text will end up in variable myText


Dan



Return to posts index

Scott McGee
Re: $.evalFile (txt, tsv, csv, xml...etc)
on Jun 15, 2017 at 7:16:31 pm

Hey Dan,

That's just what I wanted, so I don't have to worry about Excel exporting it with ""

So now I have one last question. I've not done anything like this before so I haven't the foggiest (I've tried something you put in another forum), I'm hoping you might have a solution.

It now appears

"""
"RSS FEED"\r"
"RSS FEED"\r"
"RSS FEED"\r"
"""

Is there an expression to only read a single line?

I have 3 text layers. In the feeds they contradict one another, which is why I would prefer not to do it this way, but I have to make the best of a crappy situation.

I've included \r to paragraph it, but I don't know how to get Text 1 to look at line 1, Text 2 to look at Line 2 and Text 3 to look at Line 3.

I can't substr it, as the character length will differ everyday so it needs to look at the line. I saw you gave an expression to "lineIdx", I've tried playing around with it, with no success.


Return to posts index

Dan Ebberts
Re: $.evalFile (txt, tsv, csv, xml...etc)
on Jun 15, 2017 at 8:15:25 pm

Not tested, but you should be able to do something like this:


myText = $.evalFile(myFile);
mySplit = myText.split("\r");
mySplit[0]; // for the first line


If your text lines actually have" \r" characters in them, it may mess things up so that you would have to use mySplit[2] for the second line and mySplit[4] for the third line. You'll have to experiment.


Dan



Return to posts index


Scott McGee
Re: $.evalFile (txt, tsv, csv, xml...etc)
on Jun 16, 2017 at 7:59:52 am

Genius,

I replaced \r with another symbol that will never be used so I can use [0],[1],[2] and so forth.

Cheers for the help.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]