Going Stellar

Home/Google Sheets reference

Google Sheets function · Web and import

IMPORTDATA in Google Sheets: syntax and examples

IMPORTDATA fetches a CSV or TSV file from a URL and spreads it over the cells from the formula down and to the right. The file must be reachable without a login.

Syntax

IMPORTDATA(url)

Arguments

ArgumentTypeRequiredWhat it does
urltextyesThe address of a .csv or .tsv file, with the protocol (http:// or https://), in quotes or as a cell reference.

Examples

The examples use this table, starting in A1:

Source
public CSV
=ARRAY_CONSTRAIN(IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv"), 3, 4)

Result:

Month195819591960
JAN340360417
FEB318342391

Imports a public CSV with monthly figures and keeps the first three rows and four columns.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=ROWS(IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv"))

Result: 13

Number of rows in the file, header included.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=INDEX(IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv"), 2, 1)

Result: JAN

One cell of the import: second row, first column.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=SUM(INDEX(IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv"), 0, 2))

Result: 6530

The second column as numbers, summed. The header text is skipped by SUM.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=COUNTA(IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv"))

Result: 52

How many cells the import filled.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

Common errors

  • The URL needs its protocol. =IMPORTDATA("not a url") returns #N/A.
  • The argument is required: =IMPORTDATA() also returns #N/A, so the error alone does not tell you which problem you have.
  • The file must be reachable without a login, because the fetch runs on Google servers, not in your browser.

Compared with Excel

Same syntax in Excel is not available: Excel has no IMPORTDATA, and the nearest tools are Power Query or the Data, From Text/CSV import.

Sources

  1. IMPORTDATA (Docs Editors Help)

Markdown version · All functions