HTML Table Reader

Name: HTML Table Reader

Author: Kevin Neal

Version: 0.5

Created: Apr 2008

Modified: July 2008

Purpose: Extracts data from a table on a web page. One record is added to the data stream for each row in a table, except the first row which is used to identify property names. All records will have a property 'HTML Table Index' to denote which table they came from.

Requirements: Pipeline Pilot 6.1 or later
Reporting Collection

O/S: any

Limitations: Does not handle a table that has a title. It views the title as the property name for the first column.

Keyword: generator read html table reader pilotscript regular expression regex unmerge

Contents: HTML Table Reader.xml
HTML Table Reader Example.xml

Installation:

1. Unzip the archive.
2. Open the HTML Table Viewer Example protocol with Pipeline Pilot.
3. Run the protocol.

Answers 5
HP
HP 2008-07-22
Same contents and instructions.

Updated to Version 0.6.

Improvements:
-Ignores nested tables
-Ignores table "Title"

Note that expressions were replace with parsing to support first improvement above.

Feedback is encouraged! Please leave a comment/thought/question/suggestion/request/demand/etc.
comment imagecomment image
HP
HP 2008-07-24
To see how v 0.6 improves handling of nested tables, first take a look at how v 0.5 would handle a nested table:









A B
One Two>



UnoUna

Dos
Ichi Ni


So, version 0.5 will grab anything from the first "". Unfortunately, the nested table contains the first end table tag, so the table is truncated in the middle of the third row. You'd get a single data record, and the property "A" would contain "One".

With version 0.6, the nested table will be preserved as html in the property. Just pipe this into another html table reader.

The example table brings up another issue. What if the table only contains one row? Or the first row is data instead of property names? Well, 0.7 addresses these issues by allowing you to name the columns.

If you must use version 0.5, make sure to remove the checkpoint that I accidentally left in...

Enjoy! And as always, feedback and examples are welcomed.
comment imagecomment image
HP
HP 2008-07-29
Thanks Kevin,

I'll give it a whirl. As I mentioned off-line I did manage to get what I wanted out of v05, but v0.7 does sound a more elegant solution.

Noj
HP
HP 2008-07-29
Ok... I admit that I think this is an interesting project, but I'm even more interested in what kind of use case demands this component. Is this aimed at trying to interface with some not-so-open cheminformatics app? This seems like a very difficult problem to solve correctly in the general case. Most browsers are pretty loose in the HTML that they require to show a table, so assuming correct HTML isn't always safe. Also, much non-trivial legacy HTML would frequently use tables for layout (with accompanying heavy use of colspan and rowspan for cells), so those would make the task even trickier. So, what are people using this for?
HP
HP 2008-08-12
Hi Chris,

I'm using this for a web-scraping application, with some of the Text Analytics components. So no, not ChemInformatics, but Competitive Information!

Noj