ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

leading zeros in csv file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • leading zeros in csv file

    Hi All:

    I read somewhere (probably here) that if I put my numeric field in quotes and preceed the first quote with = leading zeros will be retained in the csv file.
    (="001" will be displayed as 001 when opened as a csv file.)

    I wrote the program to create the csv file that way and it LOOKED great with leading zeros.

    The problem is that when I click on the cell I see ="001"

    Is there some way to convert 001 to a text format so I can retain the leading zeros?

    Thanks in Advance
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

  • #2
    Re: leading zeros in csv file

    Why does a numberic field need to contian leading zeros? I guess you want it to be a text field.

    Spread sheet text data (is what you want to do)' "001" defines in the spread sheet that this field is text data. You don't need the = sign.

    Good Luck
    Bill
    "A good friend will bail you out of jail,
    A true friend would be sitting beside you saying,
    'Wow, that was fun.'"

    Comment


    • #3
      Re: leading zeros in csv file

      Hi Bill:

      Thanks for the reply.

      The Vendor requires it to be text and display as 001. Using just quotes still zero suppresses when called up in excel.

      I know I can call it a text file, Import it to excel, and change each field from "GENERAL" to "TEXT" on the import but I was looking for something more automated.

      Thanks
      Gls
      Last edited by GLS400; September 21, 2007, 11:24 AM.
      The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

      Comment


      • #4
        Re: leading zeros in csv file

        Well you're right on that one...what a pain.

        Wrap it in single quotes. I get the 003 and it alos shows the single quotes in the cell. '003'
        Bill
        "A good friend will bail you out of jail,
        A true friend would be sitting beside you saying,
        'Wow, that was fun.'"

        Comment


        • #5
          Re: leading zeros in csv file

          or even better, mess them up and put a dollar sign in front....lol
          Bill
          "A good friend will bail you out of jail,
          A true friend would be sitting beside you saying,
          'Wow, that was fun.'"

          Comment


          • #6
            Re: leading zeros in csv file

            Simple - use a single quote as in "'001"


            John McKay
            jmckay@mckaysoftware.ie
            John McKay
            jmckay@mckaysoftware.ie
            http://www.rpglanguage.com

            Comment


            • #7
              Re: leading zeros in csv file

              Nope double quotes didn't work. It still comes out as 1 in excel. That is what I suggested way up top. Then I test it further. No go.
              Bill
              "A good friend will bail you out of jail,
              A true friend would be sitting beside you saying,
              'Wow, that was fun.'"

              Comment


              • #8
                Re: leading zeros in csv file

                double quote - single quote - zero - zero - one - double quote
                " ' 0 0 1 "

                John McKay
                jmckay@mckaysoftware.ie
                John McKay
                jmckay@mckaysoftware.ie
                http://www.rpglanguage.com

                Comment


                • #9
                  Re: leading zeros in csv file

                  Originally posted by John
                  double quote - single quote - zero - zero - one - double quote
                  " ' 0 0 1 "
                  When you CLICK on the cell, you can see '001 (single quote 001) not 001.
                  The only way I found to not get the quote was in using the MC Press Online SQL2CSV and SQL2XLS utilities by Giuseppe Costagliola.
                  Philippe

                  Comment


                  • #10
                    Re: leading zeros in csv file

                    format the cells in excell to pad leading zeroes ????

                    or does it have to be automatic ?
                    Greg Craill: "Life's hard - Get a helmet !!"

                    Comment

                    Working...
                    X