Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects CSV driven graphics

  • CSV driven graphics

    Posted by Bojan Drobnjak on April 10, 2022 at 6:18 pm

    I have a project on my hands and am in need of your help, good people of internet!

    My goal is to create a simple weather forecast graphics, driven by data from a spreadsheet.

    At the moment I have a simple CSV looking like this:

    city temp icon

    Podgorica 25 sunny.png

    Budva 26 cloudy.png

    Kotor 32 rainy.png

    First column being the city, second column temperature and third should point to appropriate icon(sunny, cloudy, rainy, etc..)

    Im struggling with how to achieve this inside of AE. The first two were pretty straight forward, import CSV into the project, place it on the timeline and pick whip appropriate data from CSV to the text layers.

    But how do I do it with the icons? The files are imported into the project but I have no idea how to work out linking them to the CSV data.

    I beg for assistance!

    Allan Barnwell replied 4 years, 1 month ago 4 Members · 3 Replies
  • 3 Replies
  • Alex Hayward

    April 13, 2022 at 10:15 pm

    As far as I’m aware, the only way you are able to update an image via .csv data would be using a script. Try something like this:

    function runWeatherScript(){

    app.beginUndoGroup("Run Weather Script");

    var masterComp = findItem("CHANGE TO MASTER COMP NAME",0);

    // Error check, makes sure script has a comp to target

    if(masterComp == null){

    alert("Master comp not found");

    return

    };

    // Import the CSV file

    var csvFile = File.openDialog("Please select the CSV file containing the weather info", "CSV Files:*.csv");

    // Open the file and push all data into an array

    var csvData = [];

    csvFile.open("r");

    do {

    csvData.push(csvFile.readln());

    } while(!csvFile.eof);

    csvFile.close();

    //Loop through each line of the CSV file - start on 1st line of actual data

    for (var i = 1; i < csvData.length; i++) {

    // Seperate current row into each cell

    var curRow = csvData[i].split(",");

    // Variables for each column, easier to follow

    var city = curRow[0];

    var temp = curRow[1];

    var iconName = curRow[2];

    // Create copy of master comp for us to work in and rename to the city

    var newComp = masterComp.duplicate();

    newComp.name = city;

    // Change city text

    newComp.layer("CHANGE TO CITY TEXT LAYER NAME").property("Source Text").setValue(city);

    // Change temperature text

    newComp.layer("CHANGE TO TEMPERATURE TEXT LAYER NAME").property("Source Text").setValue(temp);

    // Get right icon

    var icon = findItem(iconName,csvData.length)

    // Change Icon

    newComp.layer("CHANGE TO ICON IMAGE LAYER NAME").replaceSource(icon,false);

    }

    app.endUndoGroup();

    }

    function findItem(x,length){

    for (var i = 1; i < app.project.numItems+length; i++) {

    if (app.project.item(i).name === x) {

    return app.project.item(i);

    break;

    }

    }

    }

    var csvData = [];

    runWeatherScript();

    It assumes all the layers you are changing are within the same comp and not pre-composed. Name the layers that will be changing in your project file and update the code to match those names. Let me know if any issues and I’ll try and help 🙂

  • Walter Soyka

    April 14, 2022 at 3:24 pm

    You could sequence all your icons, one frame each, in a precomp. Enable time-remapping for the precomp. Either use the CSV file to directly reference the frame number, or write an expression that translates the text inputs to the precomp’s time.

  • Allan Barnwell

    June 11, 2022 at 5:49 pm

    While Dataclay Templater doesn’t support CSV (due to the inability to write data back to the CSV without scrambling the file structure), it does support TSV as well as JSON files. And it supports Google Sheets as well. Plus you get all the additional power – like full batch rendering as well as support for automating other 3rd-party solutions or your own custom scripts.

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