in reply to TableExtract Module won't get complete first row!

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re: TableExtract Module won't get complete first row!

Replies are listed 'Best First'.
Re^2: TableExtract Module won't get complete first row!
by jaydon (Novice) on Nov 15, 2005 at 16:08 UTC

    Thank you for that eloquent reminder. I did forget to paste my code. Apologies. Here it is.

    my @bcfHeaders = [qr/Month\s*/, qr/First\s*/, qr/High\s*/, qr/Low\s*/, qr/Sett\s*/, qr/Chg\s*/, qr/Vol\s*/, qr/BWAVE\*\s*/, qr/Prev Vol\s*/, qr/Open\s*Int\s*/]; my $te = HTML::TableExtract->new( headers => @bcfHeaders, keep_headers => 1 ); $te->parse_file($filename); my ($ts, $row, $record); foreach $ts ($te->tables) { foreach $row ($ts->rows) { $record = join("\t", @$row); print $filehandle $record . "\n"; } }

      Ok, you're creating an array, @bcfHeaders, of one element: an arrayref. That arrayref has a bunch of stuff. Then you pass in the array to HTE's constructor where it expects a reference to an array. Two mistakes do make a right. Sometimes. That probably should be:

      my @bcfHeaders = (qr/Month\s*/, qr/First\s*/, qr/High\s*/, qr/Low\s*/, qr/Sett\s*/, qr/Chg\s*/, qr/Vol\s*/, qr/BWAVE\*\s*/, qr/Prev Vol\s*/, qr/Open\s*Int\s*/); my $te = HTML::TableExtract->new( headers => \@bcfHeaders, keep_headers => 1 );
      or you just change the @bcfHeaders to $bcfHeaders in your original code.

      All that said, I'm absolutely confident that this won't solve your real problem. Sorry.