Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
05-01-Import Data from the Web-Start.xlsx16.1 KB 05-01-Import Data from the Web-Complete.xlsx
22.5 KB 5.01 import-data-from-the-web - Exercise.docx
65.3 KB Exercise - Import Data from the Web.xlsx
15.6 KB 5.01 import-data-from-the-web - Exercise solution.docx
152.8 KB Exercise Solution - Import Data from the Web.xlsx
21.6 KB
Quick reference
Import Data from the Web
Learn how to import data from the web the easy way.
When to use
We use this method whenever we want to import data from the web into Excel without copying/pasting and then reformatting.
Instructions
Often we need to import data from a website into Excel. A common mistake is to simply copy the data from the website and then paste it into Excel. The issue with this method is that often it brings with it rogue formatting, random symbols, and other things that don't belong.
To minimize the amount of data cleaning and reformatting we need to do, we can use the Get and Transform utility in Excel which will import data from a website and format it as a table.
Import Data from the Web
- Go to the website that contains the data to import.
- Click in the URL bar and press CTRL+C to copy the URL.
- Go back to Excel.
- From the Data tab, in the Get and Transform Data group, click From Web.
- Press CTRL+V to paste the URL.
- Click OK.
Excel will scan the webpage for any tables and list them on the left-hand side of the Navigator pane. We need to click through each table until we find the one that contains the data we want to import.
- Select the table.
At this stage, we can choose to import the data directly into Excel or we can choose to transform (clean) the data in Power Query.
- Click Transform Data to open Power Query.
In Power Query, we can tidy up the data and remove anything that shouldn't be there before loading it into Excel.
Cleaning Data in Power Query
Our dataset has a couple of issues that we need to fix. For example, the column headings are repeated in the first 2 rows.
- From the Home tab, in the Reduce Rows group, click Remove Rows.
- Click Remove Top Rows.
- In the Remove Top Rows dialog box, enter 2 in the Number of rows field.
- Click OK.
Next, we need to check that each column is using the correct data type.
- Click the icon to the left of the column name.
- Change the data type accordingly.
Load the Data into Excel
Once we have cleaned our data in Power Query, we can load it into Excel.
- From the Home tab, in the Close group, click Close & Load.
- Click Close and Load To.
We can choose to load our data into an Excel Table, a PivotTable Report, a PivotChart, or we can Create Connection.
- Choose Table from the List.
- Click OK.
The data will now load into Excel as a table ready for analysis.
Hints & tips
- When we use this method, Excel creates a connection between the website data and the spreadsheet. If anything changes on the website, we just need to refresh the table to update it.
Lesson notes are only available for subscribers.