5 Replies Latest reply on Apr 3, 2016 9:23 AM by Laubender

    Delete empty rows from merged table

    rsbisa Level 1

      I'm looking for script that will seek out and delete empty rows from a table that contains merge fields.


      I have a large data table with around 800 records. This table is used to merge a one-page report that shows various components of employees income. There are about 20 rows in the table and 5 columns. I apply the merge fields to a table in my .indd file and the merge works perfectly. However, there are many income features/components that not all employees share. Consequently, all pages of the 800-page report contain several empty rows that I need to have deleted so that the remaining data rows snuggle up to each other.


      I need script that will find empty rows in an .indd's table and delete them. I found script that does this, and works perfectly on a regular table with empty rows. However, it appears that a table cell that contains a merge field (<<myField>>) is not necessarily "empty", even though the data in that field is Null. I have found that, after the merge, I can highlight an empty row, hit Delete, run the script, and the row vanishes, as needed. But, do do this manually thousands of times would defeat the purpose of the script. Also note that I have scrubbed my data file to make sure there are no hidden formulas, characters, or spaces. The "Remove blank lines for empty fields" option doesn't work on fields in table (it seems. If I'm wrong, let me know).


      It seems that I really need script that will remove references to empty merge fields after the merge. I could then run my other script.


      I've spent hours on this and hope someone can point me in a direction for a solution.



        • 1. Re: Delete empty rows from merged table
          Peter Spier Most Valuable Participant (Moderator)

          You can remove the merge field markers by doing a PLAIN TEXT find/change for <feff> and replace with nothing. That should allow your script to work.

          • 2. Re: Delete empty rows from merged table
            rsbisa Level 1



            Outstanding! I should have checked here first. This simple solution will save hours and hours of manual, tedious work.


            Thank you! !

            • 3. Re: Delete empty rows from merged table
              Peter Spier Most Valuable Participant (Moderator)

              Just to give credit where it's really due, I learned the <feff> trick from Uwe Laubender in another topic a couple of years ago. It's priceless.

              • 4. Re: Delete empty rows from merged table
                Laubender Adobe Community Professional & MVP

                Thank you for your kind words, Peter.


                Back to the special character <FEFF>.

                Be aware, that this character can stand for several things:


                1. XML tag markers

                2. Index markers

                3. Notes markers

                4. Conditional Text markers

                5. Hyperlink markers *


                * I just crashed my InDesign CS6 v8.1.0 as I tried to replace <FEFF> (a "closing" hyperlink marker) with "nothing" by using Text Search/Replace. I did not chose "Replace All", but did it step-by-step. "Replace All" did work on the same sample.


                Here a screenshot before and after removing <FEFF> with InDesign CS6 v8.1.0 on Mac OSX 10.6.8:



                As you can see replacing with nothing ( = delete) worked in the data merge case.

                But also with index markers, hyperlink anchor markers. XML tag markers and conditional text markers were not removed.


                A bit strange is the case where the "normal" character "N" of the word "Notes" was removed.
                "N" is following an InDesign note object.


                I did not test with all the CC versions…



                • 5. Re: Delete empty rows from merged table
                  Laubender Adobe Community Professional & MVP

                  On with the case for notes in text and "removing" of <FEFF> characters.

                  A note at the beginning and the end of a story will not see the effect.

                  White space before a note at the beginning of a story will not force the effect.
                  Normal text does.


                  Here another screenshot where some notes are present.
                  Text search/replace will remove text other than the <FEFF> characters every time you run the test. And it will remove more regular text the more you run search/replace on the same text with the notes.
                  Could be a bug.



                  Together with an IDML file you can download from my Dropbox account:



                  Now I had the chance to test with InDesign CC v9.3.0 and I can see no difference with the tests for CS6 v8.1.0.
                  (Mac OSX 10.6.8)


                  Can someone confirm the same results on a Windows version of InDesign?