csv deliminated file to HL7 and quotes

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf csv deliminated file to HL7 and quotes

  • Creator
    Topic
  • #53563
    Rob Parnell
    Participant

      I am trying to convert a VRL to HL7 but ran into a problem with double and single quotes.

      I have everything working except for when there are odd number of single or double quotes in one the the fields.  It no longer splits correctly after the quote

      example

      a,b,c’b,e  will display

      a

      b

      c’b,e

      if I add a,b,c’b’,e will display

      a

      b

      c’b’

      e

      Is this a know bug and how can I fix this

    Viewing 3 reply threads
    • Author
      Replies
      • #78138
        Charlie Bursell
        Participant

          It can sometimes be very hard to get VRL to do complete CSV as there are so many nuances.  Comma separated and CSV are not the same

          I would use the csv package

          set x {a,b,c’b’,e}

          package require csv

          foreach y [csv::split $x] {echo }

          I assume this is what you want?

        • #78139
          Rob Parnell
          Participant

            Here is the code that I have been testing with.  It searches the string for double or single quotes and sees if they are odd.  If they are odd then it appends a single or double quote at the end of the message.  The source file is tab delimited, I still have an issue with the modified message

            keylget args MSGID mh

            set msg [msgget $mh]

            set message [split $msg r]

            set double [regsub -all ” $message {} ignore]

            set single [regsub -all ‘ $message {} ignore]

            if {$double%2} {

                set db 1

            }

            if {$single%2} {

                set sin 1

            }

            if {[cequal $db 1] && [cequal $sin 1]} {

            set beg [crange $message 0 end-5]

            set end [crange $message end-4 end]

            set new “$beg$dbl$sing$endr”

            msgset $mh $new

            } elseif {[cequal $db 1] && ![cequal $sin 1]} {

            set beg [crange $message 0 end-5]

            set end [crange $message end-4 end]

            set new “$beg$dbl$endr”

            msgset $mh $new

            } elseif {![cequal $db 1] && [cequal $sin 1]} {

            set beg [crange $message 0 end-5]

            set end [crange $message end-4 end]

            set new “$beg$sing$endr”

             msgset $mh $new

            } else {

            }

                    lappend dispList “CONTINUE $mh”

          • #78140
            Charlie Bursell
            Participant

              A lot of work for a little result Rob

              Use the CSV package that is part of tcllib

            • #78141
              Jim Kosloskey
              Participant

                Rob,

                Perhaps I don’t have this right but I tried to duplicate your issue and I see no issue with my VRL definition and the data pattern you describe.

                What I see in the vrl testing tool is:

                Message 1

                Field 1 – a

                Field 2 – b

                Field 3 – c’b

                Field 4 – e

                Message 2

                Field 1 – a

                Field 2 – b

                Field 3 – c’b’

                Field 4 – e

                I think that is what you want.

                The raw data inbound is:

                Message 1: abc’be

                Message 2: abc’b’e

                What are the global properties and field proerties you have for the VRL is the single quote in any of the properties?

                email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

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