web stats
Override Delimiter Character - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2012, 08:12 AM
kirbyjwilson kirbyjwilson is offline
OBX.2 Kenobi
 
Join Date: May 2012
Posts: 61
kirbyjwilson is on a distinguished road
Default Override Delimiter Character

In the Outbound Message Template, I have the Data Type set to Delimited Text. If I click on Properties, I can input a character for the Column Delimiter (e.g. comma, pipe). If I leave the Column Delimiter field blank, it appears that MIRTH is inputting a default character (comma) in my output .txt file.

Is there a way I can "override" this behavior, even if it's necessary to use another Data Type for the Outbound Message Template?

BTW, the desired output will be fixed length data with no delimiters. For example:

Kirby JWilson Michael JFox
Reply With Quote
  #2  
Old 05-10-2012, 08:40 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,123
narupley is on a distinguished road
Default

Yep, just set up your outbound Delimited Text protocol settings so that the Column Widths are whatever you want (e.g. "10,10,10"), and that should override the column delimiter and set the columns up as fixed width. To be safe, you could also remove the Column Delimiter, Record Delimiter, Quote Character, and Escape Character fields, and uncheck the Double Quote Escaping, Ignore Carriage Returns, and Split Batch by Record check boxes.
Reply With Quote
  #3  
Old 05-10-2012, 09:16 AM
kirbyjwilson kirbyjwilson is offline
OBX.2 Kenobi
 
Join Date: May 2012
Posts: 61
kirbyjwilson is on a distinguished road
Default

That worked, thanks! One more thing...I can't seem to get a carriage return (i.e. newline) to work. In the Properties for the Delimited Text, I'm putting this value in for the Record Delimiter:

\n

Does it make a difference if my output file is .csv or .txt (I'm outputting a .txt)?
Reply With Quote
  #4  
Old 05-10-2012, 09:23 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,277
cory_cole is on a distinguished road
Default

Have your tried \r? I am not sure but I think in the training slides they used \r.
Reply With Quote
  #5  
Old 05-10-2012, 09:46 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,123
narupley is on a distinguished road
Default

Quote:
Originally Posted by kirbyjwilson View Post
That worked, thanks! One more thing...I can't seem to get a carriage return (i.e. newline) to work. In the Properties for the Delimited Text, I'm putting this value in for the Record Delimiter:

\n

Does it make a difference if my output file is .csv or .txt (I'm outputting a .txt)?
Did you want a carriage return or a line feed? A carriage return is 0x0D (\r), while a line feed is 0x0A (\n). "Newline" is more or less just an umbrella term; it can mean different things on different systems. Macs usually use carriage returns, Unix usually uses line feeds, and Windows usually uses both (0x0D0A).

Either \r or \n should work in the output protocol settings. Do you have more than one record being output?
Reply With Quote
  #6  
Old 05-10-2012, 10:58 AM
kirbyjwilson kirbyjwilson is offline
OBX.2 Kenobi
 
Join Date: May 2012
Posts: 61
kirbyjwilson is on a distinguished road
Default

The data does contain more than one record (it should be around 2,000 records).

I suppose what I really want is a carriage return and a line feed. But I've tried these 3 without any luck:

\n
\r
\r\n

I've attached the channel xml if someone wouldn't mind taking a look.

Thanks,

Kirby
Attached Files
File Type: xml LabData_DWToAltius.xml (8.6 KB, 36 views)
Reply With Quote
  #7  
Old 05-10-2012, 11:20 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,123
narupley is on a distinguished road
Default

From what I can see, you're only creating a single record in the delimited text XML per message. So, if you have 2,000 rows in your database that you're querying from, that will flow through your channel as 2,000 discrete messages. Of course, if you have your File Writer set to append to the file (which you do), then it should work just fine. The only hitch then is the record delimiter. Apparently, Mirth Connect only pays attention to the very first character in the Record Delimiter field. So if you have \r\n, it will only use \r as the record delimiter. This is probably something that can be improved, or maybe it's there by design.

In any case, in order to get around this, you can just include anything extra you want in the destination template. Set \r as your Record Delimiter, and then add the following JavaScript step:

Code:
$co('LF','\x0A');
Then, include that variable in your template. It should end up looking like:

Code:
${message.encodedData}${LF}
Reply With Quote
  #8  
Old 05-10-2012, 11:41 AM
kirbyjwilson kirbyjwilson is offline
OBX.2 Kenobi
 
Join Date: May 2012
Posts: 61
kirbyjwilson is on a distinguished road
Default

That worked perfectly, thanks Nick!
Reply With Quote
Reply

Tags
delimiters, fixed length, outbound

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:46 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation