Ho to remove leading zeros from a csv file which is sent from a UNIX script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ho to remove leading zeros from a csv file which is sent from a UNIX script
# 1  
Old 01-13-2017
Ho to remove leading zeros from a csv file which is sent from a UNIX script

Hi All,

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

Code:
fdate=`tail -1 abc.csv | cut -c1-8`
SUBJECT="execp : ${ENV} for ${fdate}"
destname=file_$fdate
sed 's/#BUSINESS/BUSINESS/1' abc.csv > abc2.csv
mv abc2.csv abc.csv
line_count=`wc -l abc.csv|awk '{print $1}'`
echo $line_count
if [ $line_count -gt 1 ]
then
(echo "Hi,Team";uuencode abc.csv $destname.csv) | /usr/bin/mailx -s  "${SUBJECT}"  ${TO} ${CC}

# 2  
Old 01-13-2017
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?
# 3  
Old 01-13-2017
Hi Rudi,

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
# 4  
Old 01-13-2017
and how do you open the mailed file?
# 5  
Old 01-13-2017
it comes in as an attachement.Double click
# 6  
Old 01-13-2017
Please post (shrunk but meaningful) samples of abc.csv, $destname.csv, and the target file on the remote host.
# 7  
Old 01-13-2017
Quote:
Originally Posted by karthik adiga
it comes in as an attachement.Double click
heh - good answer.
You open it with Excel?
Try opening with the notepad and see
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove the leading and trailing date from a CSV file

I'm a newbie to shell scripting. Can anyone help with the below requirement ? The leading and trailing date of a files to be removed. 2017-07-12_gmr_tag_log_20170711.csv 2017-07-12_gmr_call_log_20170711.csv 2017-07-12_gmr_outgoing_log_20170711.csv I'm looking for output like... (7 Replies)
Discussion started by: shivamayam
7 Replies

2. Shell Programming and Scripting

Remove leading zeros separated by pipe

I have a below file and I wanted to remove the leading zeros in each field separated by pipe File: 01/09/2017|2017/09/06|2017/02/06|02/06/2017|02/06/2017 06:50:06 AM|2017/02/06|02/06/2017|02/07/2017 05:45:06 AM| 02/08/2017|2017/08/06|2017/09/06|02/05/2017|02/07/2017 05:40:06... (4 Replies)
Discussion started by: Joselouis
4 Replies

3. Shell Programming and Scripting

Adding Leading Zeros for date in a file

Hello, I have a pipe separated file with two major lines. One is header and another is detail line. Header starts with H and Detail start with D. Sample Content: H|123456|Joes Watson|UK|4/5/2016|12/5/2016|3456|HC|NW|||||| D|123456|Joes... (13 Replies)
Discussion started by: Mannu2525
13 Replies

4. Shell Programming and Scripting

Help deleting leading zeros in a file

I have a list of numbers extracted and need to delete the leading zeros from them, but when i do so, the command I am using also deletes numbers that end in Zero as well. eg 10, 20, 30, etc this is part of a larger script and the only way I can think of is to try and detect the 10,20 30 etc in... (19 Replies)
Discussion started by: kcpoole
19 Replies

5. UNIX for Dummies Questions & Answers

Add leading zeros to columns in a file

Hello Gurus, Quick question. I have a file with the following records: A~000000000000518000~SLP ~99991231~20090701~88.50~USD~CS~ A~000000000000518000~SLP ~99991231~20090701~102.00~USD~CS~ A~000000000000772000~SLP ~99991231~20100701~118.08~USD~CS~ I wold like to do the following: 1. Add... (1 Reply)
Discussion started by: chumsky
1 Replies

6. Shell Programming and Scripting

awk to remove leading zeros for a hex number

Is it possible by using awk to remove leading zeros for a hex number? ex: 0000000011179E0A -> 11179E0A Thank you! (4 Replies)
Discussion started by: carloszhang
4 Replies

7. Shell Programming and Scripting

Replacing stripped off leading zeros in shell script

I have a script which is taking a 10 character variable (BOC) input by the user. If it begins with a zero, the script unwittingly strips that off, & passes a 9 characters variable. echo -n "Enter core-follow date/time for BOC: " setenv BOC $< The next bit of code picks up the 9... (4 Replies)
Discussion started by: wtaicken
4 Replies

8. Shell Programming and Scripting

excel drops leading zeros while attaching through unix

HEllo All, when the data file is being attached and mailed as file1.csv, the column data( e.g: 88E00, 99E00, 77F12, 66H18). The data 88E00 and 99E00 is being converted to 88E+01, 99E+01. All other data is fine. I need the file attached as .csv from unix only. Is there a way we can manage... (2 Replies)
Discussion started by: OSD
2 Replies

9. UNIX for Dummies Questions & Answers

Triml leading zeros in unix

Hi All, How does one trim leading zero's in unix Thanks KP. (7 Replies)
Discussion started by: kingofprussia
7 Replies

10. Shell Programming and Scripting

truncating leading zeros of a column in a file

Hi I have a file in which I have 5 columns which are delimited by “|” as shown ABC|12|YAK|METRIC|000000019.5 XYZ|10|ABX|META|000000002.5 Now my requirement is to take the last column trim the leading zero's for that column values and write back to the same file in the same... (7 Replies)
Discussion started by: nvuradi
7 Replies
Login or Register to Ask a Question