+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Exporting a Csv File with zeros as the first integer

  1. #1
    tillabong is offline x10Hosting Member tillabong is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    60

    Exporting a Csv File with zeros as the first integer

    Hello. i have a column in my database which stores values starting with 0. i've used varchar to store it so the zero shows up. however everytime i backup my database table using CSV for microsoft excel, the file opens without the zero infront. Is there any way i can prevent this so that when i reupload my csv file the zero still appears infront?

    Thanks.

  2. #2
    slacker_'s Avatar
    slacker_ is offline x10Hosting Member slacker_ is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    16

    Re: Exporting a Csv File with zeros as the first integer

    Use int instead of varchar if you're just storing numbers.

    edit:
    probably it's just an formatting issue in excel..
    Last edited by slacker_; 06-07-2010 at 11:14 AM. Reason: ...

  3. #3
    tillabong is offline x10Hosting Member tillabong is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    60

    Re: Exporting a Csv File with zeros as the first integer

    if you use int the zeros infront will not appear

  4. #4
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: Exporting a Csv File with zeros as the first integer

    Are you using them as numbers or as strings (ie like zip codes)?

  5. #5
    tillabong is offline x10Hosting Member tillabong is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    60

    Re: Exporting a Csv File with zeros as the first integer

    im storing them as strings. cause if i store as integers they wont register the 0 infront.

  6. #6
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: Exporting a Csv File with zeros as the first integer

    Why do you want the 0 in front? That is the question.

  7. #7
    tillabong is offline x10Hosting Member tillabong is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    60

    Re: Exporting a Csv File with zeros as the first integer

    for postal code. but does it really matter what i store them for?

  8. #8
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: Exporting a Csv File with zeros as the first integer

    When you import the data into Excel, don't you have an option as to the format? Import them as text, not numbers. That should preserve the leading 0's.

  9. #9
    tillabong is offline x10Hosting Member tillabong is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    60

    Re: Exporting a Csv File with zeros as the first integer

    there isnt any option for me to import as text using a csv file. and i think the problem already lies within the csv excel file because everytime i edit and save the csv excel file and then open the file again, the 0 disappears.

  10. #10
    ardnek is offline x10Hosting Member ardnek is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    12

    Re: Exporting a Csv File with zeros as the first integer

    I have found that entering a single quote (') into the Excel cell prior to your leading zeroes makes Excel treat the cell as text. This is how I format dates to prevent Excel from reformatting them (Example: '2010-05-01 is entered instead of 2010-05-01). Use "find/Replace" to put a leading quote in front of each number in Excel.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Exporting a database
    By callumacrae in forum Free Hosting
    Replies: 2
    Last Post: 09-19-2008, 12:43 PM
  2. Exporting to PDF
    By kryotek in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 05-29-2008, 05:53 PM
  3. Exporting a c++ program in MS visual c++
    By Adam01 in forum Programming Help
    Replies: 7
    Last Post: 02-12-2008, 07:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers