The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How do I extract text only from html file without HTML tag los111 UNIX for Dummies Questions & Answers 4 11-28-2007 04:40 AM
need help with html button mike171562 Shell Programming and Scripting 0 07-17-2007 05:09 PM
regarding html in c phani_sree High Level Programming 10 07-07-2007 08:47 PM
Converting HTML to CSV Jexel UNIX for Dummies Questions & Answers 3 03-18-2007 08:44 PM
perl and html marcpascual Shell Programming and Scripting 8 09-21-2005 07:47 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-22-2008
ganga.dharan ganga.dharan is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 41
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 (permalink)  
Old 01-23-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 558
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.
  #3 (permalink)  
Old 01-23-2008
ganga.dharan ganga.dharan is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 41
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
Attached Thumbnails
html-csv-htmltocsv.jpg  
  #4 (permalink)  
Old 01-24-2008
varungupta varungupta is offline
Registered User
  
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 206
Exclamation

Quote:
Originally Posted by ganga.dharan View Post
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0