Need to convert output.txt into html file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to convert output.txt into html file
# 1  
Old 08-08-2013
Need to convert output.txt into html file

I have output.txt file generated through shell scripts which need convert in tabular format using html

can you please help me


output.txt
Code:
Token  State Date1   Date2             Description                                  Name
34567 open 27/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading init chadda,Deepak kumar 
45678 open 27/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading Sizing chadda,Deepak kumar 
43567 open 27/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading DBMS info chadda,Deepak kumar 
24578 open 28/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading Trig/Proc/Syn Sharma,Vijay Kumar 
51890 open 28/06/13 28/06/13  nl21a00is-centerdb001:ncdbareq:Error in loading init Reddy,Ajay rao

# 2  
Old 08-08-2013
do you have tabs or space that delimit Description and Name ? With space delimiter, it gets difficult to distinguish where the description ends.
# 3  
Old 08-08-2013
Space delimits the Description and Name...I have a file Namelist which contain all the names.....can we compare output.txt file with Namelist to distinguish Description and Name column..
Code:
cat Namelist
Sharma,Vijay Kumar
Soni,Amit Kumar
Rajput,Anupam 
chadda,Deepak kumar
Thakral,Raj Singhalese
Sahu,chanchal ram
Reddy,Ajay rao


Last edited by Franklin52; 08-08-2013 at 03:24 AM.. Reason: Please use code tags
# 4  
Old 08-08-2013
Hi.

I have often used S Scholnick's perl code for this: T2t - text to table

Best wishes ... cheers, drl
# 5  
Old 08-08-2013
You mentioned earlier that space delimits description and name but that is not going to help because space in description itself will cause problems.

So in order to avoid complexities always create an output with fields clearly separated by any delimiter.

Anyway try this awk program and see if it helps:
Code:
awk '
        BEGIN {
                print "<html>"
                print "<body>"
                print "<table border=1>"
        }
        NR == 1 {
                print "<tr>"
                for ( i = 1; i <= NF; i++ )
                        print "<td>" $i "</td>"
                print "</tr>"
        }
        NR > 1 {
                print "<tr>"
                for ( i = 1; i <= 4; i++ )
                        print "<td>" $i "</td>"
                l = match ( $0, /[a-zA-Z0-9]*-/ )
                n = match ( $0, /[a-zA-Z]*,/ )
                print "<td>" substr ( $0, l, n - l ) "</td>"
                print "<td>" substr ( $0, n ) "</td>"
                print "</tr>"
        }
        END {
                print "</table>"
                print "</body>"
                print "</html>"
        }
' file

# 6  
Old 08-08-2013
now i will generate the output separated by delimiters.

This is working fine. Thanks a lot Yoda
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Copy the content from txt file and create a html file

I have a txt file with a list of error messages in a xml tag format, and each error message is separated with a identifier(endresult).Need to split that and copy and create a new html file.Error message has some special character. how to escape the special character and insert my data into the... (7 Replies)
Discussion started by: DevAakash
7 Replies

2. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

3. Solaris

How to convert pdf file to txt?

Hello Unix gurus, I am learning unix. I have lots pdf data files. I need to convert them into txt files. Can you please guide me how to do that? Thanks in advance. Rao (1 Reply)
Discussion started by: raopatwari
1 Replies

4. UNIX for Dummies Questions & Answers

Convert Txt file to HTML table and email

Hi all I need help converting a text file into a html table in bash and I need to email this table. The text file looks like the below. Two columns with multiple rows. Top row being header. Application Name Application Status Application 1 Open Application 2 ... (2 Replies)
Discussion started by: hitmanjd
2 Replies

5. Shell Programming and Scripting

Loop to convert text output in the HTML format

Hello Everyone, I have a sample file raw.txt as shown below : Drive Bays Bay Name : SD-2C Number of Standby Power Supplies : 4 Number of Drive Enclosures : 12 Summary Status of Contained Modules All... (6 Replies)
Discussion started by: rahul2662
6 Replies

6. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

7. Shell Programming and Scripting

SQL query output convert to HTML & send as email body

Hi , I have a sql query in the unix script ,whose output is shown below.I want to convert this output to HTML table format & send email from unix with this table as email body. p_id src_system amount 1 A 100 2 B 200 3 C ... (3 Replies)
Discussion started by: jagadeeshn04
3 Replies

8. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

9. Shell Programming and Scripting

Format txt file as html table

I have a short time to solve a problem, so I need some help. I've searched the forum, but I couldn't find a solution to my problem. I made a script to filter some text and now I have a new requirement to make it available as html table. Problem is that I more than one files with different set... (2 Replies)
Discussion started by: tetreb
2 Replies

10. UNIX for Dummies Questions & Answers

How to convert PS files to txt file?

Hi, I need to convert PS files to txt file. I thought of using ps2ascii, but its not installed in my AIX box, any other option? (2 Replies)
Discussion started by: redlotus72
2 Replies
Login or Register to Ask a Question