5

One answer to the question Wikipedia table to JSON (or other machine-readable format) suggested to use OpenRefine for handling HTML tables.

All I could find regarding OpenRefine and HTML tables were a few open issues at their GitHub repository.

Therefore my question: What is currently the best way to load data from HTML tables into OpenRefine?

4

If you're doing this interactively, most browsers will format tables as TSV when they're selected and cut. Pasting this into the clipboard dialog of Refine's project creation dialog will allow you to import the data as TSV.

If you've got a bunch to do or need to do this repeatedly, I'd use Google Spreadsheet's importHtml(url,"table",N) function which will fetch the Nth table on the given page. Refine can import directly from the resulting Google Spreadhsheet, so you can skip the export step.

If you just wanted little bits of information from lots of different tables, you could use "Add column by fetching URL" and then hand parse the interesting data out using Refine's parseHTML() with the necessary CSS selectors, but that would be pretty painful and not recommended.

3

As is often the case when handling HTML tables you will most likely need to save the table into an intermediate format that OpenRefine can accept. This is straightforward for a simple table, and is a reasonable solution for a small amount of data.

As an example, consider the simple HTML table on this webpage. First, select the table and copy to the clipboard, as below. Note the selected text is highlighted blue.

Example selected table

I'm using Excel, so can paste into a blank spreadsheet, and save in native .xls or .xlsx format.

Excel table

The resulting Excel table can now be used in OpenRefine:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.