I am trying to split a file into segments so I can strip out all the HDR segments except the first one. This is being done after the file leaves the engine because I am building a batch by stopping the thread at 11:59 p.m. and moving the file to another location and then running this code against it. The file has a CRLF after each segment per the vendor specs. Can anyone give some suggestions on what I am doing wrong.
Here is my code:
set filelist
]
set filenum [llength $filelist]
if {$filenum >0 } {
set filename [lindex $filelist 0]
set fileid [open $filename r]
set newfile
]
set segments [split $newfile nr]
Here is my result:
{HDR|300|IMF|01172007|300 MM HD BIMAGE|1.0|01172007|01172007 {PAT|0000000|DOE|JANE|A||06171978|FEMALE|11600 SOMEWHERE RD||ANYWHERE|AR|999990000|(000)555-5555||O|S|576081061} {VIS|0000000|OUTPATIENT|9999|JOHN D. SMITH|||4|300|07112006|} {GUA|DOE|JANE|A||06171978|FEMALE|11600 SOMEWHERE RD||ANYWHERE|AR|999990000|(000)555-5555||0|SELF|5987979797979||01|SOMEPLACE TO WORK|||ANYWHERE|AR|9999900000|00000000000|0} {INS|1|00217|CIGNA|POB|999999||CHATTANOOGATN374227223|(800)555-5555|||} }
Why am I getting the back-slashes and why dosn’t the first segment have a closing brace? It appears to close at the end, making it one big segment??
I have tried varying versions of nr (i.e. “nr”, n, r, “rn”) and the only thing I get different is if I use the r or “r” I don’t get the segments broken apart, it is just one big segment with two sets of braces around it.
Any suggestions or help would be appreciated.
Thanks,
Ricci Graham
501-202-4202