Enclosing fields in double quotes post VRL

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Enclosing fields in double quotes post VRL

  • Creator
    Topic
  • #49226
    Rob Galino
    Participant

      Hello all, I have a system that wants data written to fields in CSV with each field in variable length with each field, valued or not, enclosed in double quotes “”.

      Well first part is easy, VRL, set the min/max widths, that produces the VRL in default CSV.

      Next question, how would you enclosed all fields in “”?  For example:

      VRL: JOHN,DOE,M,12345678,,123 HOME STREET, APT B,HONOLULU,…

      Objective: “JOHN”,”DOE”,”M”,”12345678″,””,”123 HOME STREET, APT B”,”HONOLULU”,…

      Comments/suggestions welcome, thanks in advace!

      – Rob

    Viewing 3 reply threads
    • Author
      Replies
      • #61160
        Robert Kersemakers
        Participant

          Hi Rob,

          I was intrigued and gave it a shot: I put a double quote in the Prefix and Postfix of a the first field in the VRL and voil

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #61161
          Charlie Bursell
          Participant

            Creating and/or reading CSV files is not as simple as it seems at first glance.  There are all sorts of issues like embedded commas, unprintable characters , etc.

            There is a CSV package available as part of tcllib.  The latest version of tcllib is 1.9 and can be downloaded at:

            http://sourceforge.net/project/showfiles.php?group_id=12883&package_id=24585&release_id=452661

            (all one line)

            For those of you that do not have tcllib, I would strongly suggset you get it and install under $HCIROOT/tcl/lib/tcllib1.x

            There are many useful packages here including text manipulation, FTP, mail, CSV, etc.

          • #61162
            Rob Galino
            Participant

              Hey Robert, thanks for your input…  Everything works as you stated and actually, my VRL is set up that way…  The problem is, if there is an unvalued field, the “” will not be valued…  Here is an example:

              firstname: ch >”LEIALOHALA”< middleinit: ch >”M”<  lastname: ch >”RUSSIANRUDOMETKIN”<     blank: ch ><   Address: ch >”123455 THIS IS A VERY LONG ADD”< firstname is a field length of 10 middleinit is a field length of 1 lastname is a field length of 20 blank is a field length of 2 (and in this example, field was not valued) address is a field length of 30 If anyone knows how to always output a “” (not “”””) if the field is unvalued, problem is solved… Thanks in advance, – Rob

            • #61163
              Jim Kosloskey
              Participant

                Rob,

                This is certainly not pretty and is not tested but perhaps you could define the VRL to not put in ” for field encapsulation, then inside the Xlate CONCAT ” field ” for every field.

                Just a thought…

                Jim Kosloskey

                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.