CSV
CSV is a simple text format for tabular data. DuckDB can read CSV files from local paths, HTTPS URLs, and supported cloud storage locations, then load the results into MotherDuck tables.
How it works with MotherDuck
- Connect to MotherDuck from the DuckDB CLI, Python, or another DuckDB client.
- Use DuckDB's CSV reader to inspect local files, HTTPS URLs, or cloud storage paths.
- Create a MotherDuck table from the file when you want durable storage, sharing, or repeated queries.
Example
CREATE TABLE my_table AS
SELECT *
FROM read_csv('data.csv');
Remote CSV files
CSV files available over HTTPS or cloud storage can be queried server side in MotherDuck:
CREATE OR REPLACE TABLE my_database.main.remote_csv AS
SELECT *
FROM read_csv(
'https://example.com/path/to/file.csv',
MD_RUN = REMOTE
);
For non-local https://, s3://, gcs://, r2://, and Azure URLs, MotherDuck uses remote execution by default. MD_RUN = REMOTE makes that explicit. See the MD_RUN parameter for details.
Google Sheets CSV exports
Public Google Sheets can be queried as CSV by using the /export?format=csv URL:
SELECT *
FROM read_csv(
'https://docs.google.com/spreadsheets/d/<sheet_id>/export?format=csv&gid=<tab_id>',
MD_RUN = REMOTE
);
For private sheets, configure HTTP authentication with a DuckDB HTTP secret. See the Google Sheets integration for the full workflow.