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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
aleolsAuthor 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.