Removing comma from Address field

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Removing comma from Address field

  • Creator
    Topic
  • #50652
    Vidya Sridhar
    Participant

    I have a pre-proc in an Xlate (pipe delimited VRL input and comma delimited VRL output), which removes the comma from the Address1 field of a physician’s office address. When I run my pre-proc with echo’s in it I get the desired output of removing the comma, but when it write to the CSV file it truncates the field to have only street number in Address1 field.

    For example,

    Current format of Address1:

    111 Michigan Ave, NW

    Correct Format is

    111 Michigan Ave NW

    But csv file has only

    111 in the Address1 field.

    I have spent way too much time on trying to fix it. I would appreciate any help! Thanks!

    Here is my tcl xlt code that I call while copying Address1 field.

    proc xlt_rmv_comma_Addr1 {} {

       upvar xlateId       xlateId

     xlateInList   xlateInList

     xlateInTypes  xlateInTypes

     xlateInVals   xlateInVals

     xlateOutList  xlateOutList

     xlateOutTypes xlateOutTypes

     xlateOutVals  xlateOutVals

               set xlateOutVals ” ”

               set Addr1 ” ”                    

               assign_list $xlateInVals Addr1          

               if [regexp {[,]} $Addr1] {              

                     regsub -all {,} $Addr1 {} Addr1

                     set xlateOutVals $Addr1

                     echo “Corrected Address:” $xlateOutVals          

               } else {                                

                     set xlateOutVals $Addr1          

               }                                      

               

    }

Viewing 10 reply threads
  • Author
    Replies
    • #66977
      Anonymous
      Participant

      I find the use of the string map command to make my life much easier.

      I’m guess your issue is with the regsub command.

      So try “set xlateOutVals [ list [ [string map {“,” ” “}  $ADDR1]]”

      I’m sure someone will find something wrong with this but it works for me.

      Let me know if that fails and maybe more detail on what is going on.

      What exactly is failing?

    • #66978
      Vidya Sridhar
      Participant

      It errored on:

      errorInfo:

      invalid command name “111 MICHIGAN AVE  NW”

         while executing

      “[string map {“,” ” “}  $Addr1”

         (procedure “xlt_rmv_comma_Addr1” line 10)

         invoked from within

      “xlt_rmv_comma_Addr1”

    • #66979
      Anonymous
      Participant

      Sorry Syntax error. I typed this on the fly.

      Remove the extra Bracket after th list.

    • #66980
      Vidya Sridhar
      Participant

      That worked without any error, but I still get 111 in Address1 instead of 111 Michigian Ave NW. Any ideas why the the xlateOutVals echos correctly but while copying it only the 111 is copied. The length for all address fields are set at Max Length -1 on the VRL Configurator. I don’t understand why it truncates to the street number in the final output.

      🙁

      Thanks for you help!

    • #66981
      John Mercogliano
      Participant

      One least thing you need to remember is always treat xlateInVals and Out as a list.  You need to change your set statements to

      Code:

      set xlateOutVals [list $Addr1]

      This should populate your field correctly

      John Mercogliano
      Sentara Healthcare
      Hampton Roads, VA

    • #66982
      Vidya Sridhar
      Participant

      John,

      I set Addr1 to a list and still no luck. I am going to write up a pre-proc tcl remove the comma before the Xlate. That will get rid of it before I copy in the Xlate.

      Thank again!

    • #66983
      John Mercogliano
      Participant

      Vidya,

        One last question, when you echoed out xlateOutVals did the result from your echo look like this with the brackets;

      Code:

      Corrected Address: {111 Michigan Ave NW}

         The only other reason I can think of that it is not working is the csv file does not have the field sized correctly.  It’s important that the result you assign to xlateOutVal contain the brackets around the string or else the translator will treat this string as a list with 5 elements instead of just one element, which is how the result is looking.

      Here is how your code should look:

      Code:


      proc xlt_rmv_comma_Addr1 {} {
      upvar xlateId       xlateId
      xlateInList   xlateInList
      xlateInTypes  xlateInTypes
      xlateInVals   xlateInVals
      xlateOutList  xlateOutList
      xlateOutTypes xlateOutTypes
      xlateOutVals  xlateOutVals

      set xlateOutVals ” ”
      set Addr1 ” ”                    
      assign_list $xlateInVals Addr1          
      if [regexp {[,]} $Addr1] {              
      regsub -all {,} $Addr1 {} Addr1
      set xlateOutVals [list $Addr1]
      echo “Corrected Address:” $xlateOutVals          
      } else {                                
      set xlateOutVals [list $Addr1]
      }                                      

      }

      John Mercogliano
      Sentara Healthcare
      Hampton Roads, VA

    • #66984
      Jim Kosloskey
      Participant

      Try echoing out xlateOutVals after it is populated to see what is in it.

      If it is constructed correctly, then there may be a VRL definition issue.

      I suspect you are not getting xlateOutVals set correctly.

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

    • #66985
      Vidya Sridhar
      Participant

      John,

      It worked!   phew!

      I forgot to add the square brackets in the else statement previously, thus truncting the address field. Thanks for your help.

      Vidya

    • #66986
      Jim Kosloskey
      Participant

      Vidya,

      I am surprised that did not give you an error.

      Glad you can move forward.

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

    • #66987
      Michael Hertel
      Participant

      If it’s a single character you’re trying to eliminate a simple split/join works too.

      set xlateOutVals [join [split $xlateInVals ,] {}]

      No need to check if , is in the data first.

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

Forum Statistics

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