I am using a informatica job to create a csv file and a unix script the mail the generated file.Everything is working fine but I am not seeing leading zeros in the csv file sent in the mail.These zeros were present when the .csv file was generated by informatica procees.
Is there any command which I can use in shelll script which will dfisplay that?Please help
As there are no steps eating leading zeroes in above script, where are you "not seeing leading zeros"? In $destname.csv ? On the destination host? In a spread sheet progeam?
This unix script mails the .csv file which is already created by a informatica process.I am not seeing leading zeros when the script mails the .csv file and when we open the mail attachement.
Those zeros are present when the csv was created
I believe it's Excel eating up the leading zero-s.
Right click on attachment and open with something other than Excel.
Or save the attachment and then edit the saved file.
Shortly:
You have csv file which is something like:
00001,0012
...
And when you open in Excel by clicking your email attachment, the looks like:
1,12
...
It's Excel import default. I have not found any setup in Excel where you can change those defaults. So: M$ knows better what you need as you :). If it looks number then it's number and you don't need leading 0's. If excel import string which include only numbers then it can't be string ...
If you like to keep those leading 0's in numbered string then you need import file to Excel:
save your Attachment to some.csv
Import a text file by opening it in Excel
use wizard
setup delimiter, setup those columns to text type, not default
And you have leading 0's. So they I have planned in Seattle. It have to be difficult to say that this is string, not number.
You can use example ssconvert to convert csv to xls including some defaults ..., but if you change those fields to excel string formattadding ' before values '00001,'00012 then ssconvert ex2.csv ex2.xls 2>/dev/null fields look nice including 0's and send it.
ssconvert can be installed to the Ubuntu and Debian:
Of course, adjusting the fields so that it looks correct in Excel (or other sreadsheet programs which do the same) means that you won't be able to do any calculations on them.
You might be better to import the data as real data without any adjustments and then format the cells (or the whole sheet if you want) to fix the width of the number including leading zeros. That way the display will be correct and the value will be still numeric so you can perform calculations.