IMPORTDATA Function to Manually Import CSV Data to Google Sheets
IMPORTDATA lets you fetch data from published online CSV files. It’s a good solution, but not the best one. Why? It lacks advanced features that can improve user experience and productivity. We claim that Coupler.io can do better than IMPORTDATA, and this article is meant to prove that. So, let’s try out both solutions in real-life use cases to come to an unbiased verdict.
What is IMPORTDATA and how does it work?
IMPORTDATA is a Google Sheets function that imports data from a given URL in either CSV (comma-separated value) or TSV (tab-separated value) format.
IMPORTDATA syntax
IMPORTDATA(“URL”)
URL
is the location of a .csv or .tsv file containing the data to be imported. TheURL
must be specified, including the protocol.- Example:
=IMPORTDATA("https://www.quandl.com/api/v3/datasets/EUREX/FCPEG2020.csv?api_key=eVEFx_xdJBXEHGnmu3sc")
IMPORTDATA(reference-to-cell)
reference-to-cell
is a reference to a cell within Google Sheets, which contains theURL
.- Example:
=IMPORTDATA(C3)
IMPORTDATA formula examples
Case #1: Direct reference to the URL
=IMPORTDATA("https://www.quandl.com/api/v3/datasets/EUREX/FCPEG2020.csv?api_key=eVEFx_xdJBXEHGnmu3sc")
Case #2: Reference to the cell containing the URL
=IMPORTDATA(Sheet2!C3)
IMPORTDATA pros and cons
Pros | Cons |
---|---|
IMPORTDATA alternative for automated CSV import
Coupler.io is a tool that allows you to connect different data sources with Google Sheets, as well as Excel and BigQuery. It provides CSV as a source to import data from published online CSV files.
Note: Coupler.io is available as a web app and a Google Sheets add-on that you need to install from the Google Workspace Marketplace.
Here is how it works:
- Sign up to Coupler.io, click the Add new importer button and name your first importer.
- Choose a CSV as a source application.
- Enter the URL of your CSV file.
- Jump to the destination section and choose the Google Sheets as your data destination to import data to.
- Connect your Google account, select a spreadsheet file on your Google Drive and and a sheet to load data to. You can also create a new sheet by typing in a name.
Check out what an importer may look like:
For automated imports of CSV data, enable the Automatic data refresh and configure the schedule: interval, days of the week, time preferences, and timezone.
We blogged about this in detail in “Import CSV into Google Sheets Without Any Coding”.
Coupler.io CSV importer pros and cons
Pros | Cons |
---|---|
IMPORTDATA formulas in real-life use cases
Now, let’s check out how good both IMPORTDATA and Coupler.io are in real-life use cases. For this, we’ll inspect additional features available with each solution and demonstrate the outcome. Let the battle begin!
Data update on demand
After the initial import, you may want to update the data fetched from your online CSV file. With IMPORTDATA, you’ll have to manually execute the function. With Coupler.io, you need to click on the Run button to update the data on demand.
Data update on schedule
IMPORTDATA lacks any scheduling option.
Coupler.io provides the automatic data refresh feature. You can configure the following parameters:
- Select interval: Every 15 minutes/ 30 minutes/ Hour/ Day/ Month
- Select day of the week: Mon, Tue, Wed, Thu, Fri, Sat, Sun
- Select time preferences: From 0:00 to 23:00
- Select time zone: From UTC−12:00 to UTC+14:00.
QUERY + IMPORTDATA formula to import data with a selected number of columns
You can select the number of columns to be imported via IMPORTDATA. For this, you’ll need to apply a combination of two functions: IMPORTDATA and QUERY. For example, here is how you can select columns #1,#2, and #3:
=QUERY(IMPORTDATA("https://www.quandl.com/api/v3/datasets/EUREX/FCPEG2020.csv?api_key=eVEFx_xdJBXEHGnmu3sc"), "Select Col1,Col2,Col3")
Read our blog post about QUERY Google Sheets function to learn more data manipulation capabilities.
With Coupler.io, you can also cut off unnecessary columns. For this, there is the Fields parameter, where you need to type relevant column names separated by a comma. An extra benefit is that the order of names you specify will result in the order of columns for output. An important note is that you have to be sure such headers are the first row in the output result.
QUERY + IMPORTDATA formula to import data with a limited number of rows
Both solutions also allow you to limit the total number of rows to be imported. For IMPORTDATA, you’ll need the QUERY function again. For example, here is how to limit your output to 10 rows:
=QUERY(IMPORTDATA("https://www.quandl.com/api/v3/datasets/EUREX/FCPEG2020.csv?api_key=eVEFx_xdJBXEHGnmu3sc"), "Select * limit 10")
In Coupler.io, you can cut off the unnecessary rows using the limit
parameter in the URL query string field.
You can also skip rows from the top of the CSV file. This is useful when you want to cut off notation data before table structured data or column headers. For this, you need to specify the number of rows to be skipped in the Skip rows field of the CSV importer. Otherwise, Coupler.io will import all rows by default.
QUERY + IMPORTDATA formula to import data with conditions
Again, a combination of QUERY and IMPORTDATA broadens your importing capabilities. You can set up conditions for fetching data. For example, let’s import values in the Settle column that exceed 115:
=QUERY(IMPORTDATA("https://www.quandl.com/api/v3/datasets/EUREX/FCPEG2020.csv?api_key=eVEFx_xdJBXEHGnmu3sc"), "Select * where Col5 > 115",1)
With Coupler.io, you can use the URL query string field to make more precise requests, such as time ranges, users, and so on. This feature is usually available if you pull data from secured connections for API-styled requests. So, the parameters available will differ.
Import data from secured CSV URLs
In the examples above, we fetched data from a publicly available CSV file, which did not require any authentication. It contained an API key attached to the URL (csv?api_key=eVEFx_xdJBXEHGnmu3sc
), so IMPORTDATA had no issues with pulling data from there. However, the function won’t work the same as with secured URLs. For example, let’s try to import a Clockify report from a CSV file:
https://global.api.clockify.me/workspaces/5e450bcf1fdfac54e1b1e0e3/reports/summary?export=csv
With Coupler.io, you can cope with this task using such fields as Request headers, Request body, and HTTP method. Parameters will always differ depending on the app you’re fetching data from. Here is what it may look like:
Check out our blog posts Connect Jira Server to Google Sheets and Connect Clockify to Google Sheets for details.
Append imported data
If you want to place data from multiple sources that have the same structure and order of columns, Coupler.io provides the APPEND mode in the Destination section. You can set up a few importers and fetch data from all the CSV files without any distortion. This is quite useful for cases when you need to combine monthly reports into a single year report.
If you want to do the same using the IMPORTDATA function, you’ll have to manually place formulas to cells and apply the QUERY function to skip the first row.
Date format recognition
The data fetched with IMPORTDATA and Coupler.io differ a bit:
Google Sheets does not recognize date values and, hence, you’ll have to update their format manually after the import. With Coupler.io, you won’t need to spend your time on this.
TL;DR comparison table
Check out the table with a concise comparison of main features of IMPORTDATA and its alternative.
IMPORTDATA | Feature | Coupler.io |
---|---|---|
Each error cleans your data | Error dependency | You are always safe from data loss if any error occurs |
Maximum of 50 calls on a single spreadsheet | Limitations | Google Sheets limits or Google Sheets API limits |
No support has been officially claimed | Import from CSV links with authentication | Available |
Not supported | Data update on schedule | Available |
Available with the help of the QUERY function | Data import with a selected number of columns | Available |
Not supported | Columns reordering | Available |
Available with the help of the QUERY function | Data import with a limited number of rows | Available |
Available with the help of the QUERY function | Advanced requests | Available |
Not supported | Import data from secured URLs | Available |
Not supported | Append imported data | Available |
Manual | Date format recognition | Automatic |
Which solution should I choose for my needs?
If you import data from online published CSV docs from time to time, IMPORTDATA is likely a good fit. It’s simple to use and does not require any prerequisites. Moreover, you can enhance its import capabilities if you combine it with the QUERY function.
Coupler.io with its CSV importer is the best option for recurrent import of CSV from online published URLs, cloud storages, public-facing servers, and many more. You can automate data fetching and benefit from lots of available features. Besides, the Coupler.io team is working on different ready-to-use integrations, such as Jira Cloud, Xero, and others. Check them out on our blog. Feel free to provide your feedback in the comments section, and good luck with your data!
Back to Blog