Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have csv file which contains data 0001,0002,0003

When I open this file in excel, starting nulls are removed

Its possible to save starting nulls at opening file in excel ?

share|improve this question

migrated from stackoverflow.com Apr 22 '13 at 23:07

This question came from our site for professional and enthusiast programmers.

    
Are you asking about nulls as in " " (a space) or as in leading zeros? –  James Jenkins Apr 22 '13 at 15:52
add comment

2 Answers

up vote 3 down vote accepted

To do this, open Excel first.

Click on Data > Import from text.

You will get a window where you'll have to pick the import type. Choose Delimited then next.

In the next screen, check only comma, then next.

On this screen, click the first column in the preview box, scroll to the last column. Hold SHIFT and click the last column. This should make all the columns 'black' (you actually selected all the columns).

Now, click the radio button Text. After that, click Finish and OK to get your data as you wanted it to be!

share|improve this answer
add comment

If you are able to control the generation of your CSV file, you can force Excel to interpret the input as text by saving it as follows:

="0001",="0002",="0003"

(Be careful that you use typewriter quotes, as above, rather than curly [smart] quotes.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.