IMPORTDATA imports a CSV or TSV file from a URL into Google Sheets. Use a direct data-file link, then leave enough empty cells for the returned rows and columns.
IMPORTDATA function syntax
=IMPORTDATA(url)
The URL can be quoted inside the formula or stored in a cell. Google’s published syntax documents one argument. The examples below use that documented form.
The source must be accessible to Google’s fetch service. A local file path or a webpage requiring your browser’s signed-in session is not the same as a publicly accessible CSV link.
Import a CSV file from its URL
Put this public sample URL in A1:
https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv
Enter the following formula in A3:
=IMPORTDATA(A1)
The sample returns four columns: Month, 1958, 1959 and 1960. Its twelve monthly records follow one header row. January’s values are 340, 360 and 417.

Leave A3:D15 empty before entering the formula. The returned array needs thirteen rows and four columns. Content in the destination can prevent expansion and produce a reference error.
If Sheets displays an external-data access prompt, an editor must review it and allow access before the import can run. Organization policies may also restrict particular sources.
Filter an import with QUERY
To return only months whose 1960 value exceeds 500, use:
=QUERY(IMPORTDATA(A1),"select Col1, Col4 where Col4 > 500",1)
The result contains JUN 535, JUL 622, AUG 606 and SEP 508. The final 1 tells QUERY that the imported table has one header row.
Use Col1, Col2 and similar identifiers for this imported array. The positions refer to the returned table, so inspect its current headers before choosing columns.
QUERY filters the returned data; it does not make the source server send fewer CSV rows. For large files, use a smaller source export when available.
Import a different table
This second public file returns a small table with Name, Sex, Age, Height (in) and Weight (lbs) columns:
=IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/biostats.csv")
The first record begins Alex, M, 41, 74 and 170. Check each imported column’s type before calculating with it; separators and source formatting can affect interpretation.
Count records in an imported CSV
The cities sample contains one header row and 128 data rows in the verified version. Count the returned rows and subtract the header:
=ROWS(IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/cities.csv"))-1
This counts records, not distinct city names. In this file, City is the ninth column; the second column contains latitude minutes. Do not assume a city name is in column B.
The subtraction is appropriate for this file’s single header and lack of extra blank records. Inspect another file’s structure before applying the same count.
Select useful columns from a grade sample
The public grade file contains several fields. Select the last-name and final-score columns to create a compact result:
=QUERY(IMPORTDATA("https://people.sc.fsu.edu/~jburkardt/data/csv/grades.csv"),"select Col1, Col8 limit 5",1)
The five returned records have final scores 49, 48, 44, 47 and 45. LIMIT controls the displayed record count, while the header argument identifies the first row as labels.
Understand refreshes and loading errors
Google documents hourly update checks while the spreadsheet is open. Reloading the browser tab does not force an IMPORTDATA refresh. Treat the function as periodic importing, not a live streaming feed.
Repeated imports and frequently changing URLs can trigger loading limits. Reuse an imported table for downstream calculations where practical instead of creating many duplicate external calls.
When an import fails, open the source URL and check whether it still returns CSV or TSV data. A login page, changed path or access restriction needs a source-level fix.
Import a local CSV file instead
For a file on your computer, use File > Import > Upload. Select the file, choose the import location and separator, then click Import data.
This creates a file import rather than an IMPORTDATA URL connection. For another Google spreadsheet, use IMPORTRANGE; for a webpage table, consider IMPORTHTML.
Other Google Sheets articles you may also like