Skip to content

Instantly share code, notes, and snippets.

@kwando
Created August 22, 2024 10:22
Show Gist options
  • Save kwando/392115c99273061041d9dcd253d62872 to your computer and use it in GitHub Desktop.
Save kwando/392115c99273061041d9dcd253d62872 to your computer and use it in GitHub Desktop.
DuckDB example

Start a shell duckdb

-- creates a new in memory table for your data
create table mydata as select * from 'myfile.csv';

-- do SQL stuff to your data
update mydata set name = 'foo' where name = 'bar';

copy (from mydata) to 'myfile_updated.csv';

-- exit the shell
.q

Or if you are brave you can use the commandline directly

duckdb :memory: -c "COPY (SELECT * FROM 'myfile.csv' WHERE name = 'foo') TO 'myfile_updated.csv')"

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