Convert text file data into XL file format

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Convert text file data into XL file format
# 8  
Old 06-30-2017
Try also
Code:
awk -vDT=$(date +"%d-%b-%Y") 'BEGIN {print "Date         stat1 stat2 stat3 stat4 stat5"} {print DT, $0; DT="           "}' file
Date         stat1 stat2 stat3 stat4 stat5
30-Jun-2017 2878042 455134 3333176 24.231979  23.81
            2880246 453022 3333268 24.141338  23.81
            2879677 453495 3333172 24.310986  23.81

# 9  
Old 07-01-2017
Quote:
Originally Posted by scriptor
thx a lot Ravi for explaining the command.
one thing I am not able to understand is
why do we need to take an array of month. why we need to define it.
Code:
 
split("Jan,Feb,Mar,Apr,may,Jun,Jul,Aug,Sept,Oct,Nov,Dec", array,",");

also one more thing I an not getting mail while running the command.
once again thx a lot for explaining the command
scriptor
Hello scriptor,

That is one of the way to change digits01to12 to Jan,FEB...Dec, we could do with Rudi's code too.

Now coming on the troubleshooting part for code is not working, it is working fine for me, I am getting output when I am running it without mailx and when I am using mailx getting email too successfully. Could you please try following points.

A- Do following steps.
i- Check if any carriage characters present into your Input_file by following command.
Code:
cat -v Input_file

If you see ^M characters then you should go further.
ii- Remove carriage characters by running following commands.
Code:
awk '{gsub('\r/,"");print} Input_file > temp_file && mv temp_file Input_file

B- If option is A is NOT valid for you and your Input_file doesn't have carriage characters then you may check things like:

1- If your Input_file have any other delimiter rather than space?
2- Check if your Input_file is same as what you have posted in very first post or not?
3- Last but not the least, you haven't mentioned your O.S name so commands which me and Rudi have given will nicely work on *NIX but on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk .

Let me know how it goes then.

Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort data in text file in particular format

I have to sort below output in text file in unix bash 20170308 DA,I,113 20170308 PM,I,123 20170308 DA,U,22 20170308 PM,U,123 20170309 DA,I,11 20170309 PM,I,23 20170309 DA,U,123 20170309 PM,U,233 (8 Replies)
Discussion started by: Adfire
8 Replies

2. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

3. Shell Programming and Scripting

Convert text file to HTML tabular format.

Please provide script/commands to convert text file to HTML tabular format. No need of styles and colours, just output and a heading in table is required. Output file will be send via email and will be seen from outlook. (script required without using awk). output file content: (sar... (7 Replies)
Discussion started by: Veera_V
7 Replies

4. Shell Programming and Scripting

Need a unix script to convert date into Julian format in a text file

The 6th & 7th column of the text files represents date & time. I need this to be converted in julian format using command "date +%s -d <date>". I know the command, but dont know how to use it on the script 0 dbclstr-b IXT_Web Memphis_Prod_SQL_Full Memphis-Prod-SQL-Full-Application-Backup... (4 Replies)
Discussion started by: ajiwww
4 Replies

5. UNIX for Dummies Questions & Answers

How to convert a text file into tab delimited format?

I have a text file that made using text editor in Ubuntu. However the text file is not being recognized as space or tab delimited, the formatting seems to be messed up. How can I convert the text file into tab delimited format? (3 Replies)
Discussion started by: evelibertine
3 Replies

6. Programming

awk script to convert a text file into csv format

hi...... thanks for allowing me to start a discussion i am collecting usb usage details of all users and convert it into csv files so that i can export it into some database.. the input text file is as follows:- USB History Dump by nabiy (c)2008 (1) --- Kingston DataTraveler 130 USB... (2 Replies)
Discussion started by: certteam
2 Replies

7. Shell Programming and Scripting

Convert comma text file to Column in html format

I am trying to generate a report with below file : File1 : EQADM,edrtere9-phys,8122caef0,gpatmon,/bin/ksh,nuten Erick EQADM,edrtere11-phys,8227caef0,gpatmon,/bin/ksh,nuten Erick EQADM,edrtere3-phys,822caef0,gpatmon,/bin/ksh,nuten Erick can you help me convert it to html and add... (9 Replies)
Discussion started by: sriram003
9 Replies

8. UNIX for Dummies Questions & Answers

To convert multi format file to a readable ascii format

Hi I have a file which has ascii , binary, binary decimal coded,decimal & hexadecimal data with lot of special characters (like öƒ.ƒ.„İİ¡Š·œƒ.„İİ¡Š· ) in it. I want to standardize the file into ASCII format & later use that as source . Can any one suggest a way a logic to convert such... (5 Replies)
Discussion started by: gaur.deepti
5 Replies

9. UNIX for Advanced & Expert Users

Convert UTF8 Format file to ANSI format

:) Hi i am trying to convert a file which is in UTF8 format to ANSI format i tried to use the function ICONV but it is throwing error Function i used it as $ iconv -f UTF8 -t ANSI filename Error iam getting is NOT Supported UTF8 to ANSI please some help me out on this.........Let me... (1 Reply)
Discussion started by: rajreddy
1 Replies

10. UNIX for Dummies Questions & Answers

write data into a text file in bold format

Hi, can anyone help to write data into a text file in bold format and rollback to actual format. Thanks, Regards, Milton Y. (1 Reply)
Discussion started by: miltony
1 Replies
Login or Register to Ask a Question