Tiny C++17 program that reads a CSV, pulls a numeric column, and prints summary stats (count, invalid rows, min, max, mean, median, stddev).
cpp-csv-stats/ ├─ data/ │ └─ sample.csv ├─ bin/ ├─ main.cpp ├─ Makefile # Option A ├─ CMakeLists.txt # Option B ├─ .gitignore └─ README.md
Requires a working g++ and make.
make
./bin/csv_stats.exe data/sample.csv value
Option B: CMake
Requires CMake and a C++ compiler (MSVC, MinGW, or Clang).
mkdir build
cd build
cmake .. # or: cmake -G "MinGW Makefiles" ..
cmake --build .
# On Windows, executable is in build/Debug or build/Release or build/ (depends on generator)
One-liner without Make/CMake
g++ -std=c++17 -O2 -Wall -Wextra -o bin/csv_stats.exe main.cpp
./bin/csv_stats.exe data/sample.csv value
CLI
csv_stats.exe <path_to_csv> [column_name]
# defaults: csv = data/sample.csv, column = value
Notes
Splits by comma only (no full RFC 4180 quoting). Good enough for simple data.
StdDev here is population standard deviation. Change to sample by dividing by (n-1).