remove header from flat file

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf remove header from flat file

  • Creator
    Topic
  • #49707
    Rick Pritchett
    Participant

    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.

Viewing 9 reply threads
  • Author
    Replies
    • #63200
      John Hamilton
      Participant

      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.

    • #63201
      Rick Pritchett
      Participant

      fileset local most likey.

    • #63202
      John Hamilton
      Participant

      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.

    • #63203
      Rick Pritchett
      Participant

      any idea how to do this in a proc for reuse?

    • #63204
      Rick Pritchett
      Participant

      in an HRL would i make two different VRLs one for the header and one for the rest of the file?

    • #63205
      John Hamilton
      Participant

      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.

    • #63206
      Rick Pritchett
      Participant

      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 0

         #lvarpop msg end

         #lvarpop msg end

         msgset $mh [join $msg “L”]

        }

        lappend dispList “CONTINUE $mh”

        #echo $newsegments

        shutdown {

         return “”

        }

         }

        return $dispList

        }

    • #63207
      Charlie Bursell
      Participant

      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]

    • #63208
      Rick Pritchett
      Participant

      Yes Charlie, your guess was correct and so was your fix.

      Thank You very much!!!

    • #63209
      Chris Williams
      Participant

      Isn’t “L” just an uppercase “L”?  A formfeed would be “f”, aka CTRL-L.

Viewing 9 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,296
Replies
34,439
Topic Tags
287
Empty Topic Tags
10