Skip to content

Instantly share code, notes, and snippets.

@Bilbottom
Created May 10, 2024 20:00
Show Gist options
  • Save Bilbottom/ca53c6ef3c377844e04c7cccd90eca26 to your computer and use it in GitHub Desktop.
Save Bilbottom/ca53c6ef3c377844e04c7cccd90eca26 to your computer and use it in GitHub Desktop.
DuckDB's `FROM` statement accepts glob patterns
/*
DuckDB's `FROM` statement accepts glob patterns
DuckDB version: 0.10.2
Bill Wallis, 2024-05-10
*/
select version();
/*
You'll need to create the folders manually first:
`data/`
`data/sub/`
`data/sub/subsub/
See the following for more information:
- https://github.com/duckdb/duckdb/discussions/10665
*/
copy (select 1 as a, 2 as b, 3 as c) to 'data/one.csv';
copy (select 4 as a, 5 as b, 6 as c) to 'data/two.csv';
copy (select 7 as a, 8 as b, 9 as c) to 'data/sub/three.csv';
copy (select 0 as a, 0 as b, 0 as c) to 'data/sub/subsub/four.csv';
/* Just file headers */
from 'data/**/*.csv';
/* File headers with filenames */
from read_csv('data/**/*.csv', filename=true);
@Bilbottom
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment