Convert character encoding of a CSV file for InDesign Data Merge

InDesign’s Data Merge feature is great. This is a video I return to, when I need to use it.

There is a catch, though: the data must be in the right format for this to work with Swedish text, which has å, ä and ö.

  1. Use a spreadsheet app to make a dataset (columns and rows)
  2. Use column names without spaces, and only lower-case characters. Do not use any “special characters”. So: only between a-z.
  3. Export it to CSV format
  4. Open the Terminal app in your Mac
  5. Change to your directory where the file is by dragging its folder into the Terminal window and hit ENTER. Perhaps you need the command cd followed by a space and then drag the folder. (Tip from commenter Dima. Thanks!)
  6. Type the following text command and press ENTER to change the file filen.csv to the target format (which is called utf-16):
    iconv -f utf-8 -t utf-16 < filen.csv > filen2.csv
  7. A new file filen2.csv is created in the same directory.
  8. Use this new file in your InDesign data merge!

Nerd notes:

  • Typing man iconv will bring up a text manual for the iconv command. Try it! (Quit the manual by typing q.)
  • the < and > are “output redirection” symbols, used in two directions in this so-called pipeline

The manual taught us that the command can be expressed as:

iconv --from-code utf-8 --to-code utf-16 < filen.csv > filen2.csv

This may be easier to read.

  • Changing directory can be done using the text command cd (“change directory”), followed by the path you want to navigate to.
  • pwd is a text command that reads “print working directory”. Try it!

Published by Olle Jonsson

Human. Wears glasses and often a smile.

Join the Conversation

8 Comments

  1. My Terminal skills sucks. I got an error. But I did manage to open it in Text Wrangler and save it out as utf-16. Worked like a charm!

  2. Thank you for the hint regarding file encoding for InDesign’s data merge feature!
    I have struggled with files I created using UTF-8 encoding, now I see that UTF-16 does the right job.

  3. I was struggling with this issue for years. Thanks for writing this up!

  4. Hi,
    I am struggling with french text that also has accented characters.
    Point 2 in your guidelines : “Use column names without spaces, and only lower-case characters. Do not use any “special characters”. So: only between a-z.”
    The problem is : InDesign recognizes as image paths columns preceded with “@” (e.g. “@myimagepath), but encoding the file in utf-16 results in a wierd column name inside InDesign that cannot be affected to an image field :-(
    By chance, do you know how to fix this issue ?
    Regards,
    matt.

  5. Great guide! Using it for Czech characters.
    You might have forgotten to add “cd” for change directory in step 5 prior to dragging the folder into terminal.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.