Skip to content

Data Merge in Acorn Using a CSV File

Sample of CSV Data Merge with Acorn

Learn how to use Acorn to read a CSV (Comma Separated Value) file and generate sample employee badges.

Download our sample project

csv_employee_badge.zip

First, take a look at the data that will be added to the employee badge images. The top row contains the names of the columns (First,Last,Title,@headshot,ID,#Filename) and the subsequent lines contain actual employee data.

First,Last,Title,@headshot,ID,#Filename
Karl,Mueller,Programmer,pics/001.png,A001,FNA001
Aurora, Starling,Chief Visionary Officer,pics/002.png,A002,FNA002
Jasper, Brightwell,Master of Solutions,pics/003.png,A003,FNA003
Luna, Skye,Head of Creative Ventures,pics/004.png,A004,FNA004
Finn, Meadowbrook,Director of Innovation,pics/005.png,A005,FNA005
Ophelia, Gale,Lead Strategy Architect,pics/006.png,A006,FNA006
Rowan, Thorne,Senior Horizon Planner,pics/007.png,A007,FNA007
Marina, Crestfield,Vice President of Synergy,pics/008.png,A008,FNA008
Ezra, Hawke,Chief Dream Officer,pics/009.png,A009,FNA009
Not Familiar with CSV?

If you have never come across CSV files, you can read Wikipedia's entry on it. It's a simple text format for spreadsheet data that can be created and exported by apps such as Excel or Numbers.

Loading the CSV File

After opening the template.acorn file in Acorn (available in csv_employee_badge.zip) choose the Image ▸ Data Merge… menu item. Click on the file picker (highlighted in the image on the right) and then choose the employees.csv file.

Acorn will load up the data from the CSV file. The palette will list the names of the columns, the number of rows, and provide paging buttons to cycle through the rows to preview the images.

Assigning Variables

Next, tell Acorn which columns will change which text boxes in the template. This can be done by using the Metadata & Scripting section of the Text and Shapes palette. There are fields to change the Scripting ID of selected shapes or text boxes, as well as a field to assign Variables for script authors. The ID field will be used here.

Select the "Last Name" text box by using the move tool, and then in the shape palette scroll down to the Metadata & Scripting section. In the ID field type in "Last". Make sure to capitalize L, as it needs to be exactly the same as the column name in the spreadsheet.

Shape Palette Pro Tip

Hold down the option key while clicking on a disclosure triangle in the shape palette to close all sub palettes. You can then easily see and expand the Metadata & Scripting palette as shown in the above screenshot.

Next, select the "First Name" text box in the canvas and enter "First" for the ID. Then select the "Employee #001" text box and enter "ID". Finally, select the "Employee Title" text box and enter "Title" for the Scripting ID field.

Almost all of the column fields have been assigned to text boxes. But what about the @headshot column in the spreadsheet? That's already been assigned in the template, as one of the layers has the name "@headshot". When Acorn comes across that column it'll look for a corresponding bitmap layer name and swap in the referenced image.

Now bring up the Data Merge palette again and preview what happens when the spreadsheet data is merged with the image.

Watch the text boxes and employee faces update by pressing the paging arrows in the Data Merge Palette!

Exporting Images

The last step is to save all the images.

Click on the "Export…" button in the Data Merge palette to bring up Acorn's Export window. A number of options are available for saving the images, you can learn more on the Export & Web Export page.

Look for the Data Merge section located on the left of the window. It allows you to page through your data file to preview the various images.

After making any adjustments to the export settings, you can click the Save… button to choose a directory to write to. Acorn will export all the images to your selected folder (and will overwrite any existing images with the same name).

If your CSV file has a #Filename column, Acorn will use that to name the file. Otherwise, Acorn will choose a name based off the template's file name.

Not all export formats are available for export with Data Merge