CSV Open Excel Text Number As Text

wsnyder

Board Regular
Joined
Sep 23, 2018
Messages
224
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Using SQL Developer, Microsoft 365.
In SQL, I convert an account_number to text:
to_char(acct_nbr)

I then export to csv file
but when I open in Excel, it is a number

I then tried adding an apostrophe to the front of the acct_nbr:
''''||to_char(acct_nbr)
And exported to CSV

When I open the file an acct nbr that has 5 char's now has length of 6 char's and I can see the apostrophe.

I also tried just 2 apostrophes but when I open the file, again it is a number not text.

Thanks,
-w
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
When opening CSV files directly in Excel, Excel tries to "guess" the format of all the fields, and fields that look like numbers will be imported as numbers, which will drop leading zeroes.
You need to open the file using the "Data Import Wizard", which does not come up by default in the newer versions of Excel. You can choose to bring it back in a "legacy" view (as shown here" Text Import Wizard.), or use the method described here: Stop truncating / dropping leading zeroes when opening csv file

Either way, you want to format that field where you want to maintain the leading zeroes as Text.
 
Upvote 0
Solution
Thanks Joe,

The Text Import Wizard link solved it

Thanks,
-w
 
Upvote 0
You are welcome!

Yes, I am a little annoyed that they took that away. That used to be the default thing that popped up when importing text files.
I like it because it gives me control of the data, as opposed to letting Excel "guess", and they often guess wrong.
Since CSV files do not have any formatting, there is no way for Excel to know that numbers are supposed to be text.
 
Upvote 0
Hi,​
numbers as text between double quotes and selecting the appropriate option in the Import Wizard …​
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,218
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top