infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Read Only Archives
Cloverleaf
Tcl Library
Need to add CR at the end of each segment
Yvonne Gaffney
Does anyone have a script that will add a CR at the end of each segment?
Thanks :shock:
Find more posts tagged with
Clovertech
Comments
jcobane1
Yvonne,
If your segments aren't already terminated/delimited with a CR, how are your segments delimited so that you know it is a segment?
James Cobane
Henry Ford Health
Yvonne Gaffney
Maybe I should take the time to explain what we are trying to do, since there could be another solution.
Took a flat file and translated it to hl7, but we did not want all of the records to go to into the database. I copied the hl7 messages (hcidbdump) to a file which was then given to the user. They went through the file and removed the messages they did not want to send. Now they tried using both word and wordpad for this task. When they save the file and we put it back on the Cloverleaf we are missing the control character; in some cases we lost the CR (word) and in others we lost the NL (wordpad). Either way, I am trying to figure out how we can do this with some sanity.
Suggestions on how to save this file without loosing the control characters or the best approach at putting them back in is appreciated.
Thanks :?:
Elisha Gould
assuming there is no new lines that need to be in the message a quick solution is:
cat file.txt | awk '/^MSH/{printf "n%s",$0} !/^MSH/{printf "r%s",$0} ' > file.msg
This produces a new line separated message file.
just as a note might want to delete the first blank line after running this.
Charlie Bursell
My guess is Windows was trying to be your "friend" and put line feeds to go with the carriage returns. A simple approach use perl. If there are multiple records it may take two commands
perl -pi -e 's/n//g' file
Then to put linefeeds back after each record
perl -pi -e 's/rMSH/rnMSH/g' file
Note that file could be a single file like hl7.dat or multiple files like *.dat
assumes Unix