HTML table to CSV


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! :)

<!-- Created by Avaya CMS Supervisor 12.0 -->

Open in new window

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.

If you have access to the source code, you could try something like:

This will just take HTML and save it to a CSV so that you can do what you want with it.
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


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.