is now part of!

Using Data Merge to Create a Table for a Directory

42 0

For years we’ve been saying: Data Merge is terrible for creating directories. The reason is that InDesign’s Data Merge feature takes a “prototype” example and repeats it (either once per page, or in a grid on your pages) — that is, it duplicates the text and graphic frames themselves over and over. That makes it great for things like a yearbook or contact sheet, or business cards or anything that requires variable data within a particular layout.

But it’s terrible for directories where you just need a one long list or table of information. Until now.

Loic Aigon wrote this wonderful little free script called CSVtoTables that lets you use Data Merge with a table! Normally, Data Merge would simply duplicate the whole text frame that contains the table, which is useless. This script lets you duplicate the rows themselves, all in the same table. Here’s how it works.

Here’s the data we’re working with, in Excel:

table merge from excel

Now I save this as a CSV (comma-delimited) or TXT (tab-delimited) data file, switch to InDesign and choose Select Data Source from the Data Merge panel menu. This loads my table into the Data Merge panel. (Notice that it uses the column header row in the spreadsheet above as the name of the data tags.)

creating the prototype

I create a table in an InDesign text frame, then place the Type tool into the frame and click on each Data Merge tag I want to include. (You don’t have to include all of them.) In the example above, I’m using a two-column table with a header row. I’ve also created and applied paragraph styles to the tags inside the table. I strongly recommend you save your document/template now, so that you can revert to it later if you need to.

Now comes the magic. Select the row you want to repeat (in this case, the second row, with the data merge tags in it). You have to have the whole row selected of you’ll get a javascript error! Now run the script from the Script panel by double-clicking on it.

The result:

final result

Note that many of the “Street 2” cells were empty in the original data? that’s okay, the script strips those lines out so that they don’t appear in the final table. Yay! Because I had set the original row’s height to “At Least 3 mm” each row is only as tall as it needs to be. (Of course, if you prefer each row be exactly the same height, you can do that, too.)

By the way, the script changes the table in your current document. (That’s different than the way Data Merge normally works, which is to create a duplicate of your document.) So when you’re done, choose File > Save As, so that you don’t overwrite your original template/prototype table accidentally (you might need it again later!).

Of course, there are many other commercial plug-ins (such as Em Software’s InData) that let you create far more complex and fancy directories based on spreadsheet or database data. But for a simple directory, where you just need a long multi-page table, this free script is awesome.

You can download the script here; if you need help installing the script, read this.

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning ( are among the most watched InDesign training in the world. You can find more about David at
  • Chris Ryland says:


    Nifty, and thanks for the note re: InData.

    A direct link to the InData product page is here..

  • Loic says:

    Thanks David for this post ;)

  • This is a great find, but for me it begs the question “could it work WITHOUT the table cells?” Data Merge has had the problem that it could never emulate Word’s “Next Record” field to put the next record in the same text box, but Loic’s script has, in a way, found this via table rows… but what if the data was just repeating in the same text box without being in a table?

  • Loic says:

    Hi Colin,

    Yep great topic indeed.

  • Vinayak Mali says:

    Thanks, I will try again again …….

  • Apurv says:

    Thanks for the post. Nice application of Data Merge.

  • Stephan Möbius says:

    Perhaps I am a bit thick here, but please explain to me how this is different than using indesigns “Convert Text to Table”?

  • @Stephan: DataMerge lets you import selected data from a spreadsheet or database and format it upon import (including images). Convert Text to Table requires that everything already be formatted.

  • Margaret Gaeddert says:

    Is it possible to merge charts that are in the excel file into Indesign CS6?

  • Zalerea says:

    I cannot access the site.
    When I go to InDate/Xdata (by Em Software) it costs $400 to allow more than 50 records of data. Regardless of cost I am still not able to use this product. The Script itself is not showing up in my scripts after I install it. Is there something I am missing? Are the 2 scripts not the same?

  • Tim says:

    Hm, I’m having some difficulties with this script.
    I’ve setup 1 column with 1 row. In that one cell I’ve
    added multiple tags, with each it’s own paragraph style.
    So far, so good. But when I run the script all the generated
    input has been set to, say, “paragraph style 1+” Even though
    it should be, for example, “paragraph style 2”.

    And I just found that same goes for when you select preview, scroll
    trough preview and un-check preview.

    one style per cell works like a charm though…

  • Cindy says:

    I have 2 sets of images and multiple text frames that I want to repeat on the same page. Everything is styled but not in a table. Would the script CSVtoTables allow the second set of data to pull in the second line of content from my excell spread sheet? Right now what is happening is Indesign is repeating the data and pulling in the next line of data and pictures on the next page. Any ideas?

  • Tigre says:

    Most excellent! I’ve been trying to overcome the DataMerge duplication pain and this is the ticket!

    I’m using Tick for time tracking and it exports a simple CSV and I was doubting that I’d have to import every DataMerge tag into every cell. Halleluja!

    • Tigre says:

      Ahhh, poop. Too excited. I followed the instructions and it tells me “done” after flashing two new documents and promptly closing them. The DataMerge tags are in the table, I selected the row, and then it does nothing but flash those documents open/closes them and deletes the merge tags. This is in CS6.

  • Christie says:

    Is there a way I can alter this for text boxes & actions in the case of say a certificate. say I have for example an indesign doc that is a certificate going out to many people and I have an excel column listing those people… either one column full name or 2 columns first and last.

    Is there a way I could re-purpose this to add names to the text field, going down the column in order and saving the file as a pdf with actions every time a name is changed.

    So the script would run; change the name. this could then trigger the action, the action would save the files a pdf and that would trigger the script to add the next name.

    Kind of complex; my knowledge of scripts is currently limited but it would be cool and useful for lots of things.

  • Emma says:

    Your data merge tuts have helped me so much!
    Do you know of any way to make it work with arabic text as well though?

  • Christie says:

    Ok thanks I haven’t ever used the Data Merge feature. I will have to look into that, I just assumed it would involve a script but I am not an advanced indes user… more intermediate ha I’ll take a look at that thanks!

  • Joe says:

    This is a great script, but I’m wondering if there’s a way to attach a link to an actual cell, but the cells can disappear if the CSV has no info in the cell upon import (allowing for rows to be omitted as necessary)?

  • Dave says:

    I’m having issues using this script in InDesign CS6. Whenever I run the script, another window in InDesign opens with a tiny text box in the corner. When you expand the box and the table inside, it just has the merge fields in there.

    Has anyone else encountered this problem and found a solution? Thanks.

  • Becky says:

    Is it possible to add additional rows of information?
    (“Select the row you want to repeat (in this case, the second row, with the data merge tags in it). You have to have the whole row selected of you’ll get a javascript error! Now run the script from the Script panel by double-clicking on it.”)

    I’m wanting to do 6 rows of information (an entire name and address block) and when I select them I only get the first row of information.

  • Rob says:


    Ive got a crazy data merge that i’m not sure is possible.. heres my simplified data

    image, style name, size, price

    first problem I want to have 1 image for 5 records that all have the same image. no idea how to do this?

    2nd problem Id then like to turn it into an order form (interactive pdf) so has a quantity for each row.

    please help!

  • briggs says:

    HI can anyone help me? I have a catalogue already done but for design reason I have to convert all the text frames into table as they are…. in the document I have 100s and 1000s of text boxes and to convert each text box into table one by one will take me for ever, do you have any script where I can select all the text boxes and convert into table?


    • I have never seen anything that will convert frames into tables; that would be very difficult, I think. This script will merge frames into one, but it won’t create tables:

      • Briggs says:

        Hi and thanks for the reply. I have found something on google and that is exactly what I need but the problem is it is converting table into 4 rows and not one…

        I need one row, one column and no border.. infect if I can apply table Style like top-Line would be great.. I am a graphic designer and not a computer expert so dont understand the languages… If you can have a look at the codes below and correct it for me?

        var myText = app.activeDocument.selection[0].texts[0];
        var myTable = myText.convertToTable();

        really appreciate and many thanks. (also this only does the one table and not all selected.. it would be nice if I select all and convert all but if not one would be fine.. it saves me doing manual all, with this script I just have to click, much faster than going into each table, select and convert)

  • Matt says:


    I’ve used this script before multiple times but I am trying to use it again on a new project and I can’t for the life of me get it to display my images.

    I have 12 columns in landscape and have them all tagged correctly. I have the image frame in the 12th column tagged correctly as well. The filepaths in the .csv are correct. When I run the script it fills out all the columns and rows with the data except the images. The tagged image frame just remains in the first row. If I goto preview in the data merge window before running the script it will load the first image of the first data entry.

  • chris climer says:

    I would like to create a directory listing with just text flowing in from different columns from excel.

    EG- create this repeated with two hard returns within text column and next set of information applied with paragraph styles applied when imported:
    First Last name
    City, State 00000
    (000) 000-0000

    From this excel columned document:

    First Last name (Column 1) Address (Column 2) City (Column 3) State (Column 4) Zip (Column 5) Phone (Column 6)

    I would like to be able to change the excel document and able to update within InDesign. Also be able to apply tabs to different pages.


  • Todd F. says:

    I must be missing something simple. How would I update the data in the table from the csv when changes are made without deleting the data in ID and re-running the script? Is this not possible with this script?

    • Todd: No, data merge (and this script) does not update data. It just has a very simple brain. You have to rerun it if the data changes. (There are commercial plug-ins that are smart like that.)

      • Veaullus says:

        Hello, could you please tell me which commercial plug-ins could do the job ?
        (I just update my indesign, and then the csvtotable script doesn’t work anymore).

        Thank you.

  • Todd says:

    Any word on what commercial software does this or if this is something that ID has added?

  • Rick Burress says:

    I’m trying to automate the pagination of only two sizes of page ads: Full page and half page (from saved PDFs.)
    My problem is that in no way can I seem to automate the two half pages coming together as one when necessary, while continuing to add the full pages. I’ve tried Data Merge Multiple Records, Tables, Loic’s scripts (Anchored Data merge & CSV to Tables). Help please!

  • Petra Richli says:

    Hi, Thanks for this tutorial. Script still works with cc2018.

  • Hannah says:

    I have everything set up with paragraph styles and linked in the data merge window but I am unable to preview the merge or run the script.

    Amy ideas on how to fix this?

    • Hannah says:

      I fixed the preview issue but I am still unable to run the script. When I double click or right click and hit run script nothing happens. I know it can take a few minutes but still nothing happens…

      • Hannah says:

        I found the issue. When I installed the script to the Application folder not user, the script worked perfectly.

  • Miranda says:

    Thank you for the script! I had a few issues at first, but figured out they were because of the excel formatting.

    Many of the data fields had multiple entries which caused data to input into the wrong fields. My work around was to prep the excel sheets with commas with no space between info in one field. Then once the script runs in InDesign I use find and replace to replace all commas with a return. Easy!

    This will save me a TON of time in the long run. Thanks again.

  • >