Skip to Content

INTERNET_CSV

Overview

The INTERNET_CSV function allows you to import data from any public CSV file on the internet directly into Excel. By providing a URL to a CSV file, the function fetches the file, parses its contents, and returns the data as a 2D list (range) suitable for use in Excel formulas. This is meant primarily as an example you can build off of for functions requiring access to data on the internet.

The function automatically prepends the URL with https://cors.boardflare.com/ before fetching the file. This proxies the request and appends the CORS headers required by the browser.

Usage

To use the INTERNET_CSV function in Excel, enter it as a formula in a cell, specifying the direct URL to the CSV file you want to import:

=INTERNET_CSV(url)
  • url (string, required): The direct URL to the CSV file you want to import.

The function returns a 2D list containing the parsed CSV data (each row is a list of strings), or an error message as a string if an exception occurs.

Examples

Example 1: Importing Zillow Market Heat Index Data

In Excel:

=INTERNET_CSV("https://files.zillowstatic.com/research/public_csvs/market_temp_index/Metro_market_temp_index_uc_sfrcondo_month.csv?t=1746621339")

Expected output:

RegionIDSizeRankRegionNameRegionTypeStateName2018-01-312018-02-28
1020010United Statescountry5050
3949131New York, NYmsaNY5252
7538992Los Angeles, CAmsaCA6967
3944633Chicago, ILmsaIL4849

Example 2: Importing Zillow New Construction Sales Data

In Excel:

=INTERNET_CSV("https://files.zillowstatic.com/research/public_csvs/new_con_sales_count_raw/Metro_new_con_sales_count_raw_uc_sfrcondo_month.csv?t=1746621339")

Expected output:

RegionIDSizeRankRegionNameRegionTypeStateName2018-01-312018-02-28
1020010United Statescountry3450833782
3949131New York, NYmsaNY532447
7538992Los Angeles, CAmsaCA333398
3944633Chicago, ILmsaIL288255

Python Code

import csv import io import requests def internet_csv(url): """ Fetches a CSV file from the internet (with CORS proxy) and returns its contents as a 2D list. Args: url (str): The direct URL to the CSV file. Returns: list[list[str]]: 2D list containing the parsed CSV data. Each row is a list of strings. str: Error message if an exception occurs. This example function is provided as-is without any representation of accuracy. """ if not isinstance(url, str) or not url.strip(): return "Error: A non-empty URL string must be provided." cors_url = f"https://cors.boardflare.com/{url}" try: response = requests.get(cors_url) response.raise_for_status() content = response.text reader = csv.reader(io.StringIO(content)) data = [row for row in reader] if not data: return "Error: CSV file is empty or could not be parsed." max_len = max(len(row) for row in data) padded_data = [row + [""] * (max_len - len(row)) for row in data] return padded_data except Exception as e: return f"Error: Failed to fetch or parse CSV: {e}"

Live Notebook

Edit this function in a live notebook.

Live Demo

Last updated on