: InDesign Data Merge and hiding missing data I have an InDesign document which is filled from the data in a CSV using data mrege. The csv has columns for name, phone, email etc, but some of
I have an InDesign document which is filled from the data in a CSV using data mrege. The csv has columns for name, phone, email etc, but some of the data in the csv isn't filled in as it is not all necessary so when InDesign gets to that record it leaves it blank. So far so good, but I have my document setup like this:
Name: Bob
Phone: 01234567890
Email: bob @ email .com
When a field is missing I end up with just a blank record and I want the data merge or a script to just hide that all together if it's missing so that if a phone number is missing I just get:
Name: Bob
Email: bob @ email .com
and not:
Name: Bob
Phone:
Email: bob @ email .com
I can't find any way of doing it, except by manually going through the generated document and that is more open to error.
More posts by @Holmes874
5 Comments
Sorted by latest first Latest Oldest Best
I format my data with my field name in the data already. If the field is blank then I don't put the field name in and the field will show up blank in your document. So my field does not look like this
Phone: << PhoneNo >>
it just looks like this << PhoneNo >>.
Using a spreadsheet it is very easy to make a simple formula to add the field name to the data where you want to or any other text or formatting for that matter. I start off with my raw data on one sheet in the workbook and then I use formulas to copy that data over in another sheet where I add the formatting that I want. Using this method, in your formula, you can test for blank cells (fields) in your raw data and replace them with a blank in the cell of your formatted result sheet. If the data is not blank then put in the field name or any other text and formatting and append the raw data to it.
Using two different sheets in the same work book, here is an example of a formula that produces a totally blank cell in my result sheet if there is no phone number in my raw data sheet or, conversely puts the label Phone No: into the cell with the actual phone number following it, in this case the actual phone number comes from cell A2 of my raw data sheet.
=IF(RawDataSheet!A2="","","Phone No: "&RawDataSheet!A2)
This formula means that if Cell A2 in my Raw Data Sheet is blank then show a blank cell in my result sheet otherwise show the text Phone No: and add the data from cell A2 in my Raw Data Sheet.
Using this method you can make all kinds of formatting of your data and also use conditional formatting if you would like. For instance you could format that phone number like this (012) 345-6789 or whatever. You just have to brush up on your spreadsheet formulas. Obviously once you spend the time to do one row of data the way you like it then you can copy it for thousands of rows and they will all produce the same result unless you have problems in your raw data but you could even test for that too.
Once this is all done I copy then paste my result sheet to a new single sheet work book using the Paste Values command and save that as a CSV file and I'm good to go. Don't forget to bring your field names over in the first row of your final sheet.
You can achieve this by
creating a character style "gone" with a font size of .1, vertical
scale of 1%, Horizontal Scale of 1% this will give you a format that will hide the text
Create a paragraph style for the text block that you what to hide empty fields in.
In that paragraph style apply a GREP style.
Apply style: gone (the character style from step 1)
To Text: ^r
Hit OK
^r looks at the beginning of a paragraph (^) for the end of a paragraph (r) you could add text string to this to hide the whole line.
so for your example you would put ^Phone:sr
this just hides the text it will not eliminate it from the document, so it may cause you issues in other ways.
IF your CSV file puts a tab in a blank field, you can do a search-and-replace for "Phone[tab]" and replace with just "[tab]." That's a little more automated than manual searching.
InDesign really has to go with the lowest common denominator when it comes to importing data. What this means is that all raw data has to be properly formatted before import, in your case removing empty fields before importing.
I am not sure that's possible unfortunately. In all my time using InDesign to do this, I've never come across an option or way to ignore the missing content's label.
It's a shame, maybe you can email Adobe and ask for it a a new feature in CS6 :D
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.