Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Extracting records from an html page

Posted on 2004-04-16
3
Medium Priority
?
151 Views
Last Modified: 2010-03-04
Hi all,
This is my very first post. I have a network appliance that sends me daily reports in html format. The goal is to input this daily data in an xl spreadsheet.

The format looks like this.

Daily Incoming Report : 01/01/2003
   Totals and Averages:
   Total Message Count                    87140
   Total Message Count (Encrypted/Signed) 10
   Total Messages (with SSL)              1498
   Total Messages (without SSL)           85642
   Total Message Volume (MB)              1441.18
   Average Messages per Hour              3630.83
   Average Volume per Hour (MB)           60.05


So far I have discovered two choices.
1, use lynx -dump html_file.html > text_file.txt which strips all the html tags, I then use sed to pull the lines I am interested in.
The dilema is to imprt those lines and files into xl.

2, I looked here and found this, but am not sure how to use it.
http://search.cpan.org/~msisk/HTML-TableExtract-1.08/lib/HTML/TableExtract.pm


Any help will be greatly appreciated.
Thanks

Noob
0
Comment
Question by:perlnoob
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
PerlKing earned 200 total points
ID: 10847941
If my understanding is correct, you know how to extract the data from the HTML tables (using either of the above mentioned approaches) but you don't know how to create an xl sheet.

I can think of two alternatives:
1. If your requirement is simple and you need just a single-sheet xl page, then all you need to do is to print the data in comma seperated format (csv). For example, in the documentation link of TableExtract.pm that you mentioned, you can see the following spippet of code in the Snopsys section:

 # Examine all matching tables
 foreach $ts ($te->table_states) {
   print "Table (", join(',', $ts->coords), "):\n";
   foreach $row ($ts->rows) {
      print join(',', @$row), "\n";
   }
 }

This code prints the extracted data in a csv format. Just make this write into a file instead and name the file "something.csv". xl will be able to open this file for you.

2. If you need a more sophisticated xl sheet to be created you, could use this module
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-0.42/WriteExcel.pm

Hope that helped
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question