Fiddler has asked for the wisdom of the Perl Monks concerning the following question:
It pretty much loops like this throughout, what i'm trying to do is convert this to a csv or something and ingest it into a DB. If i can directly write to the DB when looping through that'll be ever better. Let me know if you can help me. With any solution. P.S this is my script so far.<BR><B> 00:00 - 00:15 </B> <TABLE BORDER> <TR> <TD> Channel </TD> <TD> Call Letters </TD> <TD> Count </TD> <TD> Percent </TD> <TD> Title </TD> </TR> <TR></TR> <TR> <TD align=right> 1 </TD> <TD > ch1 </TD> <TD align=right> 22 </TD> <TD > 6.52% </TD> <TD > Program 1 </TD> </TR> <TR> <TD align=right> 3 </TD> <TD > Ch1 </TD> <TD align=right> 5 </TD> <TD > 1.48% </TD> <TD > Program2 </TD> </TR> <TR> <TD align=right> 4 </TD> <TD > Ch 3 </TD> <TD align=right> 1 </TD> <TD > 0.29% </TD> <TD > Program3 </TD> </TR> <TR> <TD align=right> 5 </TD> <TD > CH53 </TD> <TD align=right> 5 </TD> <TD > 1.48% </TD> <TD > Program4 </TD> </TR> <TR> <TD align=right> 6 </TD> <TD > C </TD> <TD align=right> 3 </TD> <TD > 0.89% </TD> <TD > Program5 </TD> </TR> </TABLE>
It only processes the FIRST table tho... not the rest of the document.use warnings; use strict; use HTML::TableExtract; use LWP::Simple; my $file ="/path/to/file/file.htm"; my $T = HTML::TableExtract->new(); my $table = $T->parse_file($file) ->first_table_found; my @rows = $table->rows; foreach my $row ($T->rows) { print join(',', @$row), "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML Table to MYSQL DB
by moritz (Cardinal) on Nov 02, 2011 at 14:58 UTC | |
| |
|
Re: HTML Table to MYSQL DB
by choroba (Cardinal) on Nov 02, 2011 at 15:01 UTC | |
| |
|
Re: HTML Table to MYSQL DB
by zentara (Cardinal) on Nov 02, 2011 at 17:12 UTC | |
by Fiddler (Initiate) on Nov 02, 2011 at 18:16 UTC | |
by Fiddler (Initiate) on Nov 03, 2011 at 15:27 UTC | |
by Fiddler (Initiate) on Nov 03, 2011 at 18:26 UTC | |
by choroba (Cardinal) on Nov 03, 2011 at 19:03 UTC | |
| |
|
Re: HTML Table to MYSQL DB
by Anonymous Monk on Nov 10, 2011 at 10:10 UTC |