Saturday, 6 February 2016

HOW TO filter columns in a HTML table within any web page

There are multiple ways to filter columns in a HTML table within any web page

1. Google Sheet can be used to scrape tabular data.

For example, by using the IMPORTHTML formula in a cell within Google Sheet it is possible to scrape the tabular data from this Wikipedia article link:
=IMPORTHTML("http://en.wikipedia.org/wiki/Demographics_of_India", "table", 4)
The table referred in the formula is the fourth among the tables on the web page referred by the URL.

Once you have the data within Google Sheet, you can filter by column value (select column header, choose Filter from Data menu) or hide column (select column, choose Hide column from context menu)

Mediawiki, the open-source wiki application that Wikipedia is based on makes it simple to make a table's columns sortable by just including the value "sortable" in the CSS class attribute for that table.

2. Stoyan Stefanov's ReactiveTable bookmarklet can work on any table (that has table header row cells enclosed within a TH tag) within any web pages including those that need to be authenticated. His blog post has instructions on how to use his bookmarklet to act upon tables to sort, filter as-you-type, download the data in CSV and JSON formats.

No comments:

Post a Comment