*! version 1.2.1 07mar2013

Title

readhtmltable -- Read a web page and convert any tables it contains to a data set

Syntax

readhtmltable

[, options]

Main
varnames Use the first row as variable names

html Keep HTML markup

debug Save intermediate results

Description

readhtmltable reads the requested web page and converts any tables it contains into a Stata data set.

Options

Main

varnames indicates that the first row of each column should be used as the variable name. If it is emtpy,
the default variable name will be used.

html keeps HTML markup (defined as anything in between < and >). By default HTML markup is removed.

debug keeps the intermediate results generated by the program which are dropped by default. Probably only useful for debugging.

Remarks

If the web page contains multiple tables they will still be placed in a single data set and it is up to the user to separate them (this may change in future versions).
The default variable names are of the form t#c# (e.g. t1c1 is table 1, column 1) but can be overridden with the option.

Note that the new data set will replace any existing data set, and this program does not (yet) check to see if anything should be saved first!

This program is in still early in the development process. Use at your own risk, but it's normally pretty easy to tell if a page has been read properly.

Examples

Read in the SSCC training schedule for the current semester

. readhtmltable https://ssc.wisc.edu/sscc_jsp/training/

Use the first row as variable names

. readhtmltable https://ssc.wisc.edu/sscc_jsp/training/, varnames

Some pages will not read properly. Here the problem is cells that take up multiple columns and/or rows (FWIW, R's readhtmlTable has the same problem with this page)

. readhtmltable http://www.nfl.com/stats/team, varnames