Skip to main content
Participant
August 4, 2022
Answered

Data Merge. Need to embed a carriage return placeholder in CSV to make hard breaks in paragraph

  • August 4, 2022
  • 1 reply
  • 1456 views

I've seen this question asked many ways... but I don't think the GREP discussions were about data merge files.  

And I've seen it here about XML data, but this method doesn't work either (https://community.adobe.com/t5/indesign-discussions/including-carriage-return-with-xml-table-data/m-p/7759546)

 

I have a text file for data merge.

I can make it csv or tab delimited or whatever else you tell me.

One of the fields is a formatted paragraph with CRs. So it forces a hard break in the txt file.  DataMerge stops reading that record at that CR.  So I can string it all into one line without any issue.  On my end, I can replace the CR with a token.

 

I've tried <br/>, and &#13; and &x0d; and all those just appear as literals in my merged data.

I've watched the "Solis" video (both).

Someone please tell me what I need to do - PLEASE!

Thanks in advance!

This topic has been closed for replies.
Correct answer Joel Cherney

Well, what I always do when I'm in your shoes is:

1) In my text editor, I replace all my hard breaks with something weird that doesn't appear in the document (Thai currency symbol, Linear B, something that would never appear in the document I'm working on) and save

2) Merge the document in ID

3) Replace the "something weird" with a hard return using Find/Change (or a soft return, if that's more appropriate to the circumstance)

 

 

1 reply

Joel Cherney
Community Expert
Joel CherneyCommunity ExpertCorrect answer
Community Expert
August 5, 2022

Well, what I always do when I'm in your shoes is:

1) In my text editor, I replace all my hard breaks with something weird that doesn't appear in the document (Thai currency symbol, Linear B, something that would never appear in the document I'm working on) and save

2) Merge the document in ID

3) Replace the "something weird" with a hard return using Find/Change (or a soft return, if that's more appropriate to the circumstance)

 

 

Participant
August 6, 2022

thx, but this doesn't really help me. 

Hope someone else has something better.

I already said I can replace the CR (carriage return) with something else, so no need for step #1.

This is something that needs to be done "automatically" with some sort of macro/script/JS/GREP style/etc.

 

Joel Cherney
Community Expert
Community Expert
August 6, 2022

GREP styles don't replace characters; we've seen some pretty edge-case uses of GREP Styles around here, so I don't want to say it's completely impossible, but it's almost completely impossible to use a GREP style to achieve what you want. 

 

These actions are scriptable, of course. I have never written my own script to automatically perform a regex on one's entire document, but the syntax looks simple enough:

 

app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.findWhat = 'heres_where_you_put_your_token';

app.changeGrepPreferences.changeTo = '\r';

app.activeDocument.changeGrep();

app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences = NothingEnum.nothing;

 

I didn't bother to test that, it's just copied and pasted from another "how do I script a regular expression" thread. It's not "automatic" because you have to run the script. I can just barely imagine a need for automagical replacement so dire that you took advantage of the InDesign Startup Scripts folder to have your script run on everything... or perhaps you make a keystroke in the Keyboard Shortcuts preferences that automagically ran the merge and performed the regex with a single keystroke? I don't know. 

 

Alternately, it's been a long time since I looked at any of InDesign's catalog plug-ins, but Peter is 100% correct when he calls Data Merge a "simplistic feature." Maybe InCatalog or EasyCatalog has what you need? Kind of overkill for your application, and also pricey to automate a single find/replace operation. Hiring one of the local script-guns-for-hire might be a better bet, if you can't turn my copypasta code above into something that meets your needs.