Data Merge in Acorn Using a CSV File¶
Learn how to use Acorn to read a CSV (Comma Separated Value) file and generate sample employee badges.
Download our sample project
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.
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