How to Use IMPORTDATA in Google Sheets

Video import data google sheet

Are you tired of manually copying and pasting data? Do you want a more efficient way to extract data from online CSV files? Look no further than Google Sheets’ IMPORTDATA function! In this article, we’ll show you how to leverage IMPORTDATA in Google Sheets with step-by-step tutorials and real-life examples.

What is IMPORTDATA in Google Sheets?

IMPORTDATA is a powerful Google Sheets function that allows you to automatically extract data from CSV or TSV files based on a given URL. Whether it’s data from a website or any online source, you can use IMPORTDATA to effortlessly retrieve the information you need.

Syntax of the IMPORTDATA Function

To use IMPORTDATA in Google Sheets, follow this syntax:

=IMPORTDATA(url)

The URL should point to a CSV or TSV file for the function to work. Make sure to enclose the URL in quotation marks. However, if you’re referencing a cell that contains the URL, there’s no need for quotation marks.

Real-Life Examples of Using IMPORTDATA in Google Sheets

1. Extracting a CSV File from a Website

One of the most common use cases for IMPORTDATA is extracting data from a CSV file. Here’s how you can do it:

  • Copy the URL of the CSV file you want to extract data from. For example, let’s use this URL pointing to an annual balance sheet in CSV format: Annual Balance Sheet.

  • Open your Google spreadsheet where you want to import the data. Enter the IMPORTDATA formula and paste the URL inside it. Here’s how it looks:

=IMPORTDATA("https://www.stats.govt.nz/assets/Uploads/Annual-balance-sheets/Annual-balance-sheets-2021-provisional/Download-data/annual-balance-sheets-2007-2021-provisional.csv")

  • Press Enter, and the data will be automatically imported into your spreadsheet.

IMPORTDATA retrieves all the available data from your source. In our example, it includes over 45,000 entries from the CSV data.

2. Using IMPORTDATA and QUERY to Limit Rows

IMPORTDATA can also import specific entries instead of the entire dataset. Here’s how:

  • To achieve this, you need to use Google Sheets’ QUERY function along with IMPORTDATA to extract specific data from a CSV or TSV file published online.

  • Enter a QUERY function before IMPORTDATA in your Google Sheets formula. The QUERY function consists of optional data, query, and header parameters.

  • Now, IMPORTDATA becomes the first parameter of your QUERY function, allowing you to use the remaining arguments to modify the imported data.

  • Your complete formula, combining QUERY and IMPORTDATA, should look like this:

=QUERY(IMPORTDATA("https://www.stats.govt.nz/assets/Uploads/Annual-balance-sheets/Annual-balance-sheets-2021-provisional/Download-data/annual-balance-sheets-2007-2021-provisional.csv"), "Select * ")

  • The above formula includes Select *, which retrieves all the data from the CSV file. To return a specific number of rows from the CSV file, you need to include the LIMIT command in the QUERY function.

  • Enter the following formula in an empty cell:

=QUERY(IMPORTDATA("https://www.stats.govt.nz/assets/Uploads/Annual-balance-sheets/Annual-balance-sheets-2021-provisional/Download-data/annual-balance-sheets-2007-2021-provisional.csv"), "Select * limit 20")

  • By adding limit 20, you limit the data import to the first 20 rows.

3. Using IMPORTDATA and QUERY to Limit Columns

In addition to limiting rows, you can also specify the number of columns to extract. You can still combine IMPORTDATA and QUERY functions, but this time, add the SELECT command to limit the columns.

Your formula should look like this:

=QUERY(IMPORTDATA("https://www.stats.govt.nz/assets/Uploads/Annual-balance-sheets/Annual-balance-sheets-2021-provisional/Download-data/annual-balance-sheets-2007-2021-provisional.csv"), "Select Col2, Col6 limit 20")

By adding Select Col2, Col6 limit 20, you instruct the function to return only the data from columns two and six up to the 20th row.

4. Using IMPORTDATA and QUERY to Extract Data Based on Conditions

You can use IMPORTDATA and QUERY functions to extract data from an online CSV file based on specific conditions. For example, you can retrieve only the data from rows containing values greater than 15,000 by using both functions and comparison operators such as >, <, and = in your statement.

For this, enter the following formula:

=QUERY(IMPORTDATA("https://www.stats.govt.nz/assets/Uploads/Annual-balance-sheets/Annual-balance-sheets-2021-provisional/Download-data/annual-balance-sheets-2007-2021-provisional.csv"), "Select * where Col7>15000 limit 20")

The formula will only return the rows with entries in the seventh column (Col7 or column G) that have values greater than 15,000.

You can also combine the VLOOKUP and IMPORTDATA functions to import data from online CSV and TSV files based on specific conditions. The IMPORTDATA function acts as a table, and the column number is the third argument of your VLOOKUP function.

Conclusion

The IMPORTDATA function in Google Sheets empowers you to easily extract data from public URLs into your spreadsheets. By understanding the various ways to use IMPORTDATA, as well as the common issues and limitations, you can make the most out of this powerful tool. If you’re looking for a more robust solution to import data from enterprise systems or other data sources, consider using data connectors like Coefficient. Coefficient is a no-code solution that seamlessly connects your Google Sheets to your enterprise systems and data sources, allowing you to import data with a single click and keep it updated in real-time. Try Coefficient for free today!

Remember, when it comes to efficient data extraction in Google Sheets, IMPORTDATA is your best friend. So, give it a try and unlock the true potential of your spreadsheets using this powerful function!

Check out Crawlan.com for more SEO tips and tricks!

Related posts