Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Lotto table extraction

by mojotoad (Monsignor)
on Jan 24, 2012 at 21:08 UTC ( #949759=note: print w/replies, xml ) Need Help??


in reply to Lotto table extraction

Those are some pretty nasty tables (50 or so of them). All sorts of empty rows and cells embedded throughout. In cases like these, it's better to extract all tables and filter based on inspecting particular cells. For example:
#!/usr/bin/perl use strict; use warnings; use LWP::Simple; use HTML::TableExtract; my $data = get('http://www.flalottery.com/exptkt/c3.htm'); my $te = HTML::TableExtract->new; $te->parse($data); for my $t ($te->tables) { my $rc = -1; my($d, $c) = $t->coords; for my $r ($t->rows) { ++$rc; @$r = map { s/^[^a-z0-9]//i; $_ } grep { /[a-z0-9]/i } grep { defined $_ } @$r; next unless @$r && $r->[0] =~ m/^\d+\/\d+\/\d+$/; print "row $d:$c:$rc: ", join(':', @$r), "\n"; } }
The grep/grep/map part eliminates empty cells and gets rid of the   entities that precede the M/E indicators. The 'next' statement afterwards eliminates empty rows and non-dated rows. This is a shotgun approach. You could easily filter each row using specific column indexes, for example.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://949759]
help
Chatterbox?
Corion is mildly surprised as some different toy projects coagulate into a useful application. I've been toying with writing a Meetup wrapper and also have been toying with synchronizing events between (CalDAV) calendars, and now that means I can ...
[Corion]: ... easily* synchronize my personal calendar with Meetup and import stuff from Meetup there
[Corion]: * Code not yet written, some restrictions may apply

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2017-02-23 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (343 votes). Check out past polls.