C++ module for CSV parsing.
  • C++ 82.9%
  • Meson 17.1%
Find a file
2026-06-18 13:09:56 -04:00
src Cleanup and formatting 2026-06-16 12:29:39 -04:00
test clangd moment 2026-06-16 23:11:54 -04:00
.clangd Prevent clangd header insertion 2026-06-18 13:09:56 -04:00
.gitignore .gitignore 2026-05-19 14:53:34 -04:00
LICENSE Initial commit 2026-05-19 14:51:26 -04:00
meson.build Add MSVC build path. 2026-06-13 02:36:48 -04:00
README.md Use first two records to estimate file size. 2026-06-15 18:07:35 -04:00

CSV Parser

C++ module for single-threaded CSV parsing.

Usage

A delimited file can be loaded into a csv::dataframe object by calling csv::parse(pathname, delimiter, buffersize). Alternatively, one can call csv::parse(pathname), which will default to delimiter= ',' and buffersize = 1 MB.

Example

import csv;
import std;

int main() {
    std::string filepath = "/path/to/file";
    char delimiter = ',';
    std::size_t buffersize = 1024*1024;

    auto parsed_data = csv::parse(filepath, delimiter, buffersize)
    if (!parsed_data.has_value()) {
        std::println("{}", parsed_data.error().message);
        return -1;
    }

    auto df = std::move(parsed_data.value());
    auto data_view = std::mdspan(df.data.data(), df.rows, df.columns);
}

Building

A build system is provided as a way to run tests and as an example on how to use the module. The project is setup to be built with Meson and requires C++23 support.

The project can be built with

  • Linux

    meson setup build
    ninja -C build
    ./build/csv
    

    , which will default to the GCC compiler if available (GCC 16+ required). Alternatively, an LLVM (LLVM 22+ required) build path is provided, available with CXX=clang++ meson setup build.

  • Windows

    meson setup build --vsenv
    meson compile -C build
    ./build/csv
    

Release builds are made available through Meson, with the command line argument --buildtype=release during the setup step: meson setup build --buildtype=release

Performance

These are the average duration of a csv::parse() call for each file.