TRXID issue

  • Creator
    Topic
  • #54179
    Tim Gobbel
    Participant

      5.6

      I had a trxid proc that was working with a quoted comma delimited file (VRL to HL7) but one of the fields I was getting had multiple commas which threw errors in the engine.  I took the file into Excel, removed the pesky field and saved as a .csv file.  Now the TRXID proc fails to provide trxids.

      proc SH_ENCtrxId {mh} {

         set trxId {}

         set data [msgget $mh]

         set fld11 [lindex [split $data ,] 16]

         set temp [string map {{“} {}} $fld11]

         switch -exact — $temp {

            “I” {set trxId “IP”}

            “E” {set trxId “IP”}

            “O” {set trxId “OP”}

            “R” {set trxId “OP”}

        }

         return $trxId ;# return it

      }

      Any ideas from you veterans!  Thanx!

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

          Tim:

          Use the csv package that is supplied as part of tcllib.

          package require csv

          set flds [csv::split $data]

          Returns a list of fields and will handle embedded commas as long as they are properly embedded (legitimate CSV file)

        • #80473
          Robert Kersemakers
          Participant

            I have my own rule: never (NEVER!) open a .csv file with Excel and then save it again as a .csv!!

            By using Excel, all kinds of things can change within the .csv files. At the least all leading zeroes will be removed from digits. But Excel could also change the delimiter, based on your country-settings within Windows.

            I see the proc uses comma as delimiter; maybe Excel has changed it in a semicolon?

            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

          • #80474
            Tim Gobbel
            Participant

              Thanx!  I had read a lot of post that indicated the csv package and that was my next step but I wanted to make sure it was not some simple thing I missed.

              The original file was text that I pulled into Excel in order to remove a column of data.  csv was the closest type to save to in order to keep the file without the unwanted data.  Any other suggestions of tools that might be able to do the same are appreciated.

              Thanx!

            • #80475
              Robert Kersemakers
              Participant

                I do a lot with Notepad++, but you can’t do any fancy editing of .csv with it.

                I have used CSVed for that once: it has a lot of options, but a bit hard to understand. There are a lot of other open source csv editors out there; there must be one to your liking.

                Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

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