HTML to csv


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HTML to csv
# 1  
Old 01-22-2008
HTML to csv

Hi !! Could you please let me know of how can a html file be converted to csv.. I am looking out for a script which could do that.. Please find the below example

<HTML><BODY><TABLE>
<TR><TD>Parent CR</TD><TD>ChildCR</TD><TD>Title</TD><TD>Description</TD></TR>
</TABLE></BODY></HTML>
<HTML><BODY><TABLE>
<TR><TD>10048</TD><TD>14950</TD><TD>CR 10048 QA Issue</TD><TD>The AutoSett xml message generated got rejected in dBCRis. </TD></TR>
<TR><TD>10048</TD><TD>15144</TD><TD>CR 10048 QA Issue</TD><TD>In the below message

The csv should not have the html headers after transformation. Thanks in advance !!
# 2  
Old 01-23-2008
Try this:

Code:
sed -n '/<TR/p' filename | sed 's/\(<TR><TD>\)\(.*\)\(<\/TD><TD>\)\(.*\)\(<\/TD><TD>\)\(.*\)\(<\/TD><TD>\)\(.*\)\(<\/TD><\/TR>\)/\2,\4,\6,\8/'


Input:

Quote:
<HTML><BODY><TABLE>
<TR><TD>Parent CR</TD><TD>ChildCR</TD><TD>Title</TD><TD>Description</TD></TR>
</TABLE></BODY></HTML>
<HTML><BODY><TABLE>
<TR><TD>10048</TD><TD>14950</TD><TD>CR 10048 QA Issue</TD><TD>The AutoSett xml message generated got rejected in dBCRis. </TD></TR>
Output:
Quote:
Parent CR,ChildCR,Title,Description
10048,14950,CR 10048 QA Issue,The AutoSett xml message generated got rejected in dBCRis.
This User Gave Thanks to dennis.jacob For This Post:
# 3  
Old 01-23-2008
thanks jacob.. it works with the piece of example that you had shown.. but when i tried with my html, it doesn't work.. Would be helpful if you can look at the attachment. The attachment is the csv image after transformation
HTML to csv-htmltocsvjpg
# 4  
Old 01-24-2008
Error

Quote:
Originally Posted by ganga.dharan
Hi !! Could you please let me know of how can a html file be converted to csv.. I am looking out for a script which could do that.. Please find the below example

<HTML><BODY><TABLE>
<TR><TD>Parent CR</TD><TD>ChildCR</TD><TD>Title</TD><TD>Description</TD></TR>
</TABLE></BODY></HTML>
<HTML><BODY><TABLE>
<TR><TD>10048</TD><TD>14950</TD><TD>CR 10048 QA Issue</TD><TD>The AutoSett xml message generated got rejected in dBCRis. </TD></TR>
<TR><TD>10048</TD><TD>15144</TD><TD>CR 10048 QA Issue</TD><TD>In the below message

The csv should not have the html headers after transformation. Thanks in advance !!

Hey,

Are you taking "comma saperated value" in unix file iteself or you are taking it in some excel file ?
If its excel file then let me know the logic for that.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting csv to html format

Below is the code I have - How can I convert the data in the csv into 3 tables in html. instead of 1 table. Attached is the format I am getting. (1 Reply)
Discussion started by: archana25
1 Replies

2. UNIX for Dummies Questions & Answers

HTML to CSV

Hi, I Have one webpage with tables and I Want to save it to csv. If I open it in Calc and export it to CSV the file its right separated how can I make the same with awk? Im attatching the webpage to convert it in CSV. (1 Reply)
Discussion started by: faka
1 Replies

3. Shell Programming and Scripting

html-to-csv

Dear, I have to format an output that is html with the tags outside the standard for a csv file. follows the input file: <table id=tabela BORDER=1 CELLSPACING=0 CELLPADDING=0 slcolor=#ffffcc dragcolor='gray' img='false' col='1' rowTotal='1' height=100% habilita_primeira='1'... (2 Replies)
Discussion started by: He2
2 Replies

4. Shell Programming and Scripting

Help needed in csv to html

Hi, Below is the code i have. But it prints entire csv line in one column. I want to print 10 comma-separated fields in 10 columns. Almost there, maybe a tweak you guys can help with. cat reports/file.csv |awk -v border=1 -v width=10 -v bgcolor=black -v f gcolor=white ' BEGIN {... (1 Reply)
Discussion started by: jakSun8
1 Replies

5. Shell Programming and Scripting

html to csv conversion

thanks for allowing me to join your forum i have a html file with three columns ------------Last visit date , URL and link,,,,,,,, how can i convert the same into csv so that i can output into database... the mechine is linux...i made a little googling and got idea that there is ways for... (2 Replies)
Discussion started by: certteam
2 Replies

6. UNIX for Dummies Questions & Answers

convert csv to html file

Hi All, I am new to this forum,not sure where to post this query...so posted here Kindly need any of your help on the below ------------ I am using shell scripting and trying to convert a csv file to html file... example.csv --------------- Name Country Age Sex Andy India 25 ... (4 Replies)
Discussion started by: sumithra
4 Replies

7. Shell Programming and Scripting

Parsing: How to go from HTML to CSV?

Dear all, I have to parse a large amount of html files, which I would like to transform into comma separated values. The html-files have the following structure: <tag1> CATEGORY_1 <tag2><tag3> HEADER_1 <tag4> <tag5> paragraph_1 <tag6> <tag5> paragraph_2 <tag6> <tag3>HEADER_2... (2 Replies)
Discussion started by: docdudetheman
2 Replies

8. Shell Programming and Scripting

HTML table to CSV

Hi !! I have HTML Tables through which i want to generate graphs, but for creating graphs i need the file in CSV format so can anyone can please help me in how can i convert my HTML table file to CSV format. Thanks in Advance (2 Replies)
Discussion started by: i_priyank
2 Replies

9. UNIX for Dummies Questions & Answers

Converting HTML to CSV

Hi, I need to convert a relatively large html file (1.5megs) into CSV under Unix. How would I be able to do this? Much thanks. (3 Replies)
Discussion started by: Jexel
3 Replies
Login or Register to Ask a Question