+ Reply to Thread
Results 1 to 13 of 13

CSV file in excel is trimming leading 0's

  1. #1
    Registered User
    Join Date
    08-19-2009
    Location
    Long Beach
    MS-Off Ver
    CA
    Posts
    43

    CSV file in excel is trimming leading 0's

    I notice that my csv list of addresses from the northeast area is trimming a lot of zip codes that atart with 0's. this is probably also happening on the address columns for some addresses or box numbers with leading 0s. is there any way to turn this function off?

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: CSV file in excel is trimming leading 0's

    Save the .csv as .txt file,

    Then when you open it, go through the wizard,

    Select Delimited, click Next, Select Commas, click next, then select the column(s) in the the preview pane that have leading zeroes and select Text from the Data Column Format area... then click Finish.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    08-19-2009
    Location
    Long Beach
    MS-Off Ver
    CA
    Posts
    43

    Re: CSV file in excel is trimming leading 0's

    this works when i save it as an xlsm file, but whenever i try to save it as a CSV, the leading zeros are trimmed again. I need to have a CSV file... is there anything else tht can be done?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: CSV file in excel is trimming leading 0's

    Save as a text file. Then rename the file to CSV. Your mileage may vary.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    08-19-2009
    Location
    Long Beach
    MS-Off Ver
    CA
    Posts
    43

    Re: CSV file in excel is trimming leading 0's

    the files can not be initially created as a .txt file. they are output as a CSV

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: CSV file in excel is trimming leading 0's

    Find the File in Windows Explorer and change the extension to .txt

    Then open that in Excel and hopefully be presented with the Text-To-Columns Wizard.

    Select Delimited and click Next

    Select Comma and click Next

    Select the column(s) you want to remain as TEXT instead of Numbers and then choose TEXT from the Column Data Format area and click Finish.

  7. #7
    Registered User
    Join Date
    08-19-2009
    Location
    Long Beach
    MS-Off Ver
    CA
    Posts
    43

    Re: CSV file in excel is trimming leading 0's

    Thanks, I believe these are the same instructions correct? To show you what occurs when I follow your instructions, I've created a camtasia recording (6 mb in size):

    http://www.filedropper.com/12610csvproblemc
    Last edited by Delta223; 01-27-2010 at 01:29 PM.

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: CSV file in excel is trimming leading 0's

    Hi Delta223
    Can you zip and attach the file?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  9. #9
    Registered User
    Join Date
    08-19-2009
    Location
    Long Beach
    MS-Off Ver
    CA
    Posts
    43

    Re: CSV file in excel is trimming leading 0's

    Hi, I zipped the file, but was unable to upload it as an attachment here. I tried to and the error response was "upload of file failed." It might be because the zip file is still about 5.7 mb,

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: CSV file in excel is trimming leading 0's

    I see what you mean.. I guess converting it back to .csv is resetting the column to numbers...

    ... not sure what else to suggest except keeping it as .txt or .xls file... which I know you don't want...

  11. #11
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: CSV file in excel is trimming leading 0's

    hi Delta223
    The only way I could keep the O's in the csv is to add a " sufix to the data.
    then format the import as text and remove the ". Looks like txt is the best option

  12. #12
    Registered User
    Join Date
    08-19-2009
    Location
    Long Beach
    MS-Off Ver
    CA
    Posts
    43

    Re: CSV file in excel is trimming leading 0's

    Ok, I finally got it to work by doing the following:

    1. changing all files to text files.
    2. delimiting the file and marking the problem columns as "text"
    3. saving the file as a tab delimited .txt file (my CSV importer was able to accept this format!)

  13. #13
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: CSV file in excel is trimming leading 0's

    well done!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1