5

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.

5 Answers 5

3

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.

2
  • Nice I had not thought of using that method. I imagine I could expand that to remove the line break at the end too. Lol for the username :) Feb 16, 2011 at 15:11
  • 1
    thanks. :) you can use search-and-replace for applying styles as well, with a bit of finagling. Feb 16, 2011 at 15:49
2

You can achieve this by

  1. 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
  2. Create a paragraph style for the text block that you what to hide empty fields in.
  3. In that paragraph style apply a GREP style. Apply style: gone (the character style from step 1) To Text: ^\r
  4. 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:\s\r

this just hides the text it will not eliminate it from the document, so it may cause you issues in other ways.

1
  • +1 This is more or less what I've done in the past when I've had this problem. Slight variation: you can make the 'invisible ghost text' thing less of an issue by putting the prefix into the CSV (so it's a column of "Phone: ...", "Phone: ...", and just "" if there's no phone, e.g, excel formula like =IF(A1="","","Phone: "&A1) - then use this trick to reduce the amount of space the empty line this still leaves takes up. Can be tricky if there's paragraph spacing though. Oct 7, 2013 at 16:35
1

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

1
  • Haha nice idea, it would be pretty useful if it was an option. Feb 16, 2011 at 14:56
1

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.

2
  • 1
    I can't actually remove the empty fields as some of the rows of data have the fields full and others don't. For example, some of the data will have a Phone number and some will have an email and some will have both. Feb 16, 2011 at 14:54
  • How are you generating the data in the first place? If you have some kind of a script generating it, then perhaps modify that the parse fields before writing. The other way to go around this, and this is a bit kludgey, is to place your data points into separate text frames, and then script checking their content, removing empty frames and altering the layout accordingly. I say this is kludgey because the data should be better parsed and written first. Feb 16, 2011 at 15:10
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.