In this tutorial, we will focus on a very useful function in Google Sheets: the IMPORTHTML function. This function allows you to import data from an HTML page directly into your spreadsheet. We will specifically look at how you can use this function to extract a list of the world's largest companies by revenue from a Wikipedia page without having to manually copy or type them.

Key Insights

  • The IMPORTHTML function allows you to import data from tables and lists on an HTML page.
  • To use this function, you need the URL of the page from which you want to extract the data.
  • You can define the data type (table or list) and the index of the table you want to import.

Step-by-Step Guide

Start by opening your Google Sheets. You want to create a new spreadsheet or open an existing one. Make sure you have enough space to integrate the imported data.

Open the Wikipedia page where the list of the largest companies by revenue is located. Copy the URL of this page. This URL will be required later to use the IMPORTHTML function.

Google Sheets: Importing data from HTML tables

In a cell in your Google Sheets, insert the IMPORTHTML function. The basic syntax of this function is: =IMPORTHTML("URL", "query type", table index). Here, you replace "URL" with the URL you copied.

Write the function so that the URL is in quotation marks. It will look something like this: =IMPORTHTML("Your_URL", "table", 1). Make sure the quotation marks are set correctly.

In this example, the goal is to import the table directly. The query type is "table" as we want to extract a table from the page. The index is 1, meaning the first table found will be imported.

Once you have entered the function correctly, press Enter. Google Sheets will then fetch the data from the specified URL and display the table in your spreadsheet.

If you want to import other tables from the same page, simply change the index in your IMPORTHTML function. For example, you can import the second table by inserting 2: =IMPORTHTML("Your_URL", "table", 2).

When you make the change, Google Sheets will fetch the new table and update the data accordingly. This is particularly useful when you need different datasets from the same source.

The IMPORTHTML function is a powerful way to quickly and efficiently integrate data into Google Sheets without the manual effort of copying and pasting. So, you can now start using this function in your projects to extract valuable data in a straightforward manner.

Google Sheets: Importing data from HTML tables

The entire function could look like this:

Google Sheets: Importing data from HTML tables

After that, you will see this result:

Google Sheets: Importing data from HTML tables

Summary

In this guide, you have learned how to use the IMPORTHTML function in Google Sheets to extract data from HTML tables. You have gone through the steps of inserting a webpage URL, specifying the correct query type, and choosing the table index. With this function, you can save time and efficiently combine needed information in your spreadsheet.

Frequently Asked Questions

What is the IMPORTHTML function in Google Sheets?The IMPORTHTML function allows you to import tables and lists from HTML pages into Google Sheets.

How do I enter the IMPORTHTML function?You use the syntax =IMPORTHTML("URL", "table", index) to import a table or list.

Can I import multiple tables from the same page?Yes, you can change the index in the function to import different tables from the same page.