Read data from excel file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Read data from excel file

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Depending on the data type of the target column, the leading zeroes may well be stripped by the database server anyway.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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:
-craig

"You can never have too many knives" -- Logan Nine Fingers
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

I got it now.Thanks Craig
Post Reply