Skip to main content
Participating Frequently
February 25, 2009
Question

Merging table rows, separating each row with a " | " character

  • February 25, 2009
  • 5 replies
  • 628 views
I'm hoping someone can help me out with this! I have very basic scripting experience and I've been beating my head against my keyboard trying to figure this out.

I'm working on a catalog for a company where all the data for the products in coming into InDesign using Easy Catalog. My problem is that the company entered the data(and lots of it!) into the database slightly wrong.

In order to import the data, I have to use a table with 1 column to import the data, then easy catalog adds a table row for each line of info. Each page would have approximately 8 tables, each with a variable number of table rows.

The data is basically a bullet list, but they don't want it displayed as such. Instead it would be like this "item1 | item2 | item3 | item4". So I'm trying to figure out how to create a script that runs through and entire document, merges every table into a single line text, separating the data in each row with the " | " character. I'm using CS3. Much thanks to anyone that can help!
This topic has been closed for replies.

5 replies

Participating Frequently
March 2, 2009
Thanks so much for your help, I'll let you know if this works on not!
Kasyan Servetsky
Legend
February 27, 2009
var myDoc = app.activeDocument;


for (i = myDoc.stories.length - 1; i >= 0; i --) {
for (j = myDoc.stories.tables.length - 1; j >= 0; j --) {
var myTable = myDoc.stories.tables;
myTable.convertToText(",", "|");
}
}
Participating Frequently
February 25, 2009
Robin! Sorry, not Rick!
Participating Frequently
February 25, 2009
Hi Rick,
Thanks for the reply! The platform is PC, JavaScript would be preferable. As for the tables, I don't actually need them at all, all I need is convert the table to text. So I just have a normal text frame with no tables in it.

Much much appreciation for your help!
Known Participant
February 25, 2009
what platform - PC or MAC - and which language do you prefer - JavaScript, VisualBasic, AppleScript ?

you need to iterate all tables (from back) and insert " | " at beginning of each cell and then merge all cells, or you can convert table to text with " | " as both separators and then convert Paragraph back to table - if you need one-cell-table instead of multi-cell-tables

robin

--
www.adobescripts.com