Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › remove header from flat file
was wanting to know how to go about using the lvarpop command to just remove the first line of a flat file (the headers). The records are not in HL7 format but are a csv. With a carriage return line feed at the end.
How you do this is very dependent or can be on the protocol you have setup.
What is the protocol you are using for this? Andif you are reading the whole file or a line at a time out of the file.
fileset local most likey.
Two options.
I have used both of these but as I’m getting older I am tending more towards the second option.
One create a TPS tcl proc to parse down the message.
Or create an HRL With a header and data segment.
any idea how to do this in a proc for reuse?
in an HRL would i make two different VRLs one for the header and one for the rest of the file?
Yes let me go find a proc and post it for you.
For the HRL you would need two VRL one for the header one for the data.
this is what i have so far. for some reason it only deletes the first half of the first line and returns the rest with the output.
proc Lvarpop_segments { args } {
global HciConnName
set mode [keylget args MODE]
switch -exact — $mode {
start {
return “”
}
run {
set mh [keylget args MSGID]
set dispList
set msg [split [msgget $mh] “L”]
lvarpop msg 0
#lvarpop msg 0
#lvarpop msg end
msgset $mh [join $msg “L”]
lappend dispList “CONTINUE $mh”
#echo $newsegments
shutdown {
return $dispList
You are spliting on a form feed character while I would bet your files are new-line delimted.
Try this:
set msg [split [msgget $mh] n]
Then you can pop off the first line
lvarpop msg
If you are sure the last record has only form feed
lvarpop msg end
While testing to be sure of what is popping off do it like:
echo HEADER: [lvarpop msg]
echo TAIL: [lvarpop msg end]
Yes Charlie, your guess was correct and so was your fix.
Thank You very much!!!
Isn’t “L” just an uppercase “L”? A formfeed would be “f”, aka CTRL-L.