Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

5 Answers 5

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.

share|improve this answer
    
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 :) –  Designer023 Feb 16 '11 at 15:11
    
thanks. :) you can use search-and-replace for applying styles as well, with a bit of finagling. –  Lauren Ipsum Feb 16 '11 at 15:49

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

share|improve this answer
    
Haha nice idea, it would be pretty useful if it was an option. –  Designer023 Feb 16 '11 at 14:56

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.

share|improve this answer
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. –  Designer023 Feb 16 '11 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. –  Philip Regan Feb 16 '11 at 15:10

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.

share|improve this answer
    
+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. –  user568458 Oct 7 '13 at 16:35

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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