HTML table to CSV

Hi,

I'm looking for some help with getting pointed in the right direction for something that already does this or with something that can help out.

I have a file exported from our Avaya CMS wich I need to get into a MySQL table. I guess using one PHP script for the job is a good choice, but not that important if its easier to first wash the html to a .csv formatted file, then run a mysql import script on that file.

I can probably play around with the .csv to mysql things later, so this is really just to get it perfectly over to csv.

The html file do have more rows, but here are a short version with the same values that will occur down the td's.

Thank you in advance for your replies! :)
<HTML>
<HEAD>
<TITLE>title</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">

<!-- Created by Avaya CMS Supervisor 12.0 -->
<P>
<TABLE BORDER=1 CELLPADDING=1 CELLSPACING=0>
<TR>
<TH><B>1</B></TH>
<TH><B>2</B></TH>
<TH><B>3</B></TH>
<TH><B>4</B></TH>
<TH><B>5</B></TH>
<TH><B>6</B></TH>
<TH><B>7</B></TH>
<TH><B>8</B></TH>
<TH><B>9</B></TH>
<TH><B>10</B></TH>
<TH><B>11</B></TH>
<TH><B>12</B></TH>
<TH><B>13</B></TH>
</TR>
<TR ALIGN=RIGHT>
<TD ALIGN=LEFT><B>1</B></TD>
<TD ALIGN=LEFT><B>LABEL1</B></TD>
<TD><B>0</B></TD>
<TD><B>0</B></TD>
<TD><B>&nbsp;</B></TD>
<TD><B>0</B></TD>
<TD><B>:00</B></TD>
<TD><B>0</B></TD>
<TD><B>&nbsp;</B></TD>
<TD><B>&nbsp;</B></TD>
<TD><B>&nbsp;</B></TD>
<TD><B>0</B></TD>
<TD><B>0</B></TD>
</TR>
<TR ALIGN=RIGHT>
<TD ALIGN=LEFT><B>2</B></TD>
<TD ALIGN=LEFT><B>LABEL2</B></TD>
<TD><B>0</B></TD>
<TD><B>0</B></TD>
<TD><B>:00</B></TD>
<TD><B>0</B></TD>
<TD><B>:00</B></TD>
<TD><B>0</B></TD>
<TD><B>0:00</B></TD>
<TD><B>:00</B></TD>
<TD><B>0</B></TD>
<TD><B>0</B></TD>
<TD><B>0</B></TD>
</TR>
</TABLE>
</BODY>
</HTML>

Open in new window

aleolsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
aleolsConnect With a Mentor Author Commented:
I was hoping for a bit script like answer. I'm pretty sure I have way too many lines to handle the job, but as this gives me the output i want it'll do :)

Thanks for the help anyways Death :)
sed -i '1,24d' 1_300.HTML
sed -i 's|<TD ALIGN=LEFT>|;|g' 1_300.HTML  
sed -i 's|<TR ALIGN=RIGHT>||g' 1_300.HTML
sed -i 's|<B>||g' 1_300.HTML
sed -i 's|</B>||g' 1_300.HTML
sed -i 's|&nbsp;||g' 1_300.HTML
sed -i 's|<TR>||g' 1_300.HTML
sed -i 's|</TR>|NEXTLINECSV|g' 1_300.HTML
sed -i 's|</TD>||g' 1_300.HTML  
sed -i 's|<TD>|;|g' 1_300.HTML
sed -i 's|</TABLE>||g' 1_300.HTML
sed -i 's|</BODY>||g' 1_300.HTML
sed -i 's|</HTML>||g' 1_300.HTML
sed -i '/^$/d' 1_300.HTML
sed -i -n -e ":a" -e "$ s/\n//gp;N;b a" 1_300.HTML
sed -i 's|NEXTLINECSV|\n|g' 1_300.HTML
sed -i 's/^.//' 1_300.HTML

Open in new window

0
 
Death259Commented:
If you have access to the source code, you could try something like: http://www.cs.iupui.edu/~aharris/H2Text.html

This will just take HTML and save it to a CSV so that you can do what you want with it.
0
All Courses

From novice to tech pro — start learning today.