How sum a big csv file

Product:
DuckDB v1.5.5 (Variegata)

Issue:

How sum a big csv file?  Excel is to small.

Solution:

Download DUCKDB, that is an embedded column-oriented database purpose-built for analytical workloads (OLAP).
DuckDB load your data in memory on your laptop, and then let you use SQL querys to find out information.
DuckDB’s SQL parser is derived from the pg_query library (https://www.sqlite.org/cli.html) , which is itself derived from PostgreSQL’s SQL parser that has been stripped down as much as possible.

On windows download the duckdb zip file, and unzip it to a folder like c:\duckdb. Go to that folder with powershell and enter DUCKDB to start the program.  https://duckdb.org/install/?platform=windows&environment=cli

 .\duckdb.exe

To import a csv file, that use European characters (note it use Linux syntax, forward slash for folders) , use a command like this:

create table budget as select * from read_csv_auto('c:/temp/db/datatabell.csv' , encoding='Latin-1') ;

This will create a in-memory databas called budget, that you can query, like to list number of rows:

select count(*) from budget ;

To get a sum for a month (note that it differs for small and capital letters  Month and month are two different columns):

select sum(amount) from budget where Månad='01' and År=2027;

Enter below to get a quick glance of what column names exist in the database table:

select * from budget ;

Then you can see the name and if it is int64 or varchar.   To find rows with zero as value, enter:

select * from budget where amount = 0;

 

To stop duckdb enter  .exit.  When you  exit duckdb the database is erased.

 

More Information:

DuckDB’s architecture delivers several distinct advantages over traditional databases and data analysis tools:

  • Vectorized query execution — Processes data in batches of 2048 rows, maximizing CPU cache efficiency and enabling SIMD acceleration
  • Columnar storage — Only reads the columns your query requests, dramatically reducing I/O compared to row-based systems
  • Direct file querying — Query CSV, Parquet, and JSON files directly without importing them first — a massive productivity boost
  • Hybrid execution — Supports both in-memory and on-disk processing, automatically spilling to disk when datasets exceed available RAM
  • Full SQL standard compliance — Supports complex queries including window functions, CTEs, PIVOT, and UNION that go far beyond what Excel or Pandas can do
  • Multi-language support — First-class bindings for Python, R, Java, Node.js, C++, Rust, and many more
  • Extension ecosystem — Load extensions for HTTP/S3 access, full-text search, spatial data, and more

How DuckDB Compares to Alternatives

Aspect DuckDB SQLite Pandas PostgreSQL
Storage model Columnar Row-based In-memory Row-based
Analytics perf ⚡ Fast Slow Fast (fits RAM) Moderate
Setup time Seconds Seconds Minutes (env) Hours (server)
Max dataset >RAM (spills) <RAM <RAM >RAM
SQL features Full Basic No native SQL Full

 

https://duckdblab.org/en/post/duckdb-beginners-guide-2026/ 

https://duckdb.org/docs/lts/data/csv/overview

https://duckdb.org/docs/current/guides/file_formats/csv_import

https://duckdb.org/docs/current/sql/introduction

https://motherduck.com/blog/duckdb-tutorial-for-beginners/

https://www.sqlite.org/cli.html

https://en.wikipedia.org/wiki/DuckDB

https://github.com/davidgasquez/awesome-duckdb 

https://duckdblab.org/en/cheatsheet/

https://duckdb.org/docs/current/sql/dialect/friendly_sql

Query Features