Page 1 of 1

Read data from excel file

Posted: Wed Aug 29, 2007 1:41 pm
by sri75
Hi ,

Our input data is in excel file, to read that file I converted to csv (comma delimited)
but here is one issue,

few columns have leading zeros in original excel file.When I converted to CSV , all leading zeros are disappeared.So I am not able to load them into target table.
When I open it as a text file I see zeros.Can you please help me out in converting excel to csv

Thanks
Sri

Posted: Wed Aug 29, 2007 2:31 pm
by chulett
Change the column's format to Text or use a custom mask to force Excel to preserve the leading zeroes: '000000' for a six digit number, for example.

Posted: Wed Aug 29, 2007 4:18 pm
by ray.wurlod
Depending on the data type of the target column, the leading zeroes may well be stripped by the database server anyway.

Posted: Wed Aug 29, 2007 5:06 pm
by chulett
My assumption was the leading zeroes are significant and the target field was thus some flavor of a string field. I have that 'problem' all the time with Excel, the 'business' supplies data in spreadsheets and the values should be something like '003287', but Excel will drop the leading zeroes unless the proper steps are taken.

It also has a problem with numeric values with a precision greater than 16, from what I recall. :evil:

Posted: Thu Aug 30, 2007 6:17 am
by sri75
Craig and Ray -Thanks for your reply .

Craig, as you said , I saved columns as text filed and loaded them into table now I see leading zeros.

I don't understand the second option you mentioned

"use a custom mask to force Excel to preserve the leading zeroes".Can you pease tell me how to do this

Thanks
Sri

Posted: Thu Aug 30, 2007 7:40 am
by chulett
Actually, I gave a specific example for that.

Format Cells, Number, Custom. Scroll through the 'Type' list to see all of the ones there by default, manually add one if need be. The '0' means you want to preserve any leading zeroes in that position.

So if I type in '123' but I need it to be '000123' then a Custom mask of '000000' will do the trick.

Posted: Thu Aug 30, 2007 7:41 am
by sri75
I got it now.Thanks Craig