Fast, compact, and easy-to-use binary format for time-series data
Combines CSV simplicity with binary performance and compression
Versioning: Since v1.5.0, library version and file format version are unified. A single version (from git tags) is stamped into every
.bcsvfile header. Package versions (PyPI, NuGet) track the same version. See VERSIONING.md for details.
BCSV combines the ease of use of CSV files with the performance and storage efficiency of binary formats. It's specifically designed for time-series data on both high-performance and embedded platforms.
- ๐ฆ 15-25% of CSV size with LZ4 compression (3-4% with Zero-Order Hold)
- ๐ 3.6M-7.5M rows/second processing speed (8-33 columns, Zen3 CPU)
- ๐ฏ Self-documenting format - no separate schema files needed
- ๐ Streaming I/O - process datasets larger than available RAM
- ๐ก๏ธ Crash-resilient - recover data from incomplete writes
- ๐ Multi-language - C++, Python, C#/Unity support
- โก Real-time capable - constant-time operations for embedded systems
Anyone running metrology, data acquisition, or telemetry tasks - from embedded systems to HPC clusters.
Header-only library - just include the directory:
#include <bcsv/bcsv.h> // C++ APIOr build with CMake:
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
./build/bin/bcsv_gtest # Run tests#include <bcsv/bcsv.h>
#include <iostream>
int main() {
// Define schema
bcsv::Layout layout;
layout.addColumn({"timestamp", bcsv::ColumnType::DOUBLE});
layout.addColumn({"temperature", bcsv::ColumnType::FLOAT});
layout.addColumn({"sensor_id", bcsv::ColumnType::UINT16});
// Write data
bcsv::Writer<bcsv::Layout> writer(layout);
if (!writer.open("measurements.bcsv", true)) {
std::cerr << writer.getErrorMsg() << "\n";
return 1;
}
writer.row().set(0, 1234567890.0);
writer.row().set(1, 23.5f);
writer.row().set(2, uint16_t{42});
writer.writeRow();
writer.close();
// Read data
bcsv::Reader<bcsv::Layout> reader;
if (!reader.open("measurements.bcsv")) {
std::cerr << reader.getErrorMsg() << "\n";
return 1;
}
while (reader.readNext()) {
auto timestamp = reader.row().get<double>(0);
auto temp = reader.row().get<float>(1);
auto id = reader.row().get<uint16_t>(2);
std::cout << "Sensor " << id << ": " << temp << "ยฐC @ " << timestamp << "\n";
}
}See examples/quickstart.cpp for a self-contained runnable version. For delta encoding, direct access, and error handling examples, see examples/.
Result: 84% size reduction (105MB CSV โ 16.3MB BCSV) with full type safety.
- docs/API_OVERVIEW.md - Compare C++, C, Python, C# APIs with examples
- docs/ERROR_HANDLING.md - Error handling patterns and best practices
- docs/INTEROPERABILITY.md - Cross-language file compatibility
- ARCHITECTURE.md - Design decisions and binary format specification
- VERSIONING.md - Automated versioning system
- examples/ - C++ usage examples
- src/tools/CLI_TOOLS.md - CLI tools documentation (csv2bcsv, bcsv2csv, bcsvSampler, bcsvGenerator, ...)
- python/README.md - Python package (pandas + Polars integration)
- csharp/README.md - C# NuGet package (.NET 8/10) with Sampler, CSV, columnar I/O
- unity/README.md - Unity game engine integration
- benchmark/README.md - Benchmark quick-start and script-friendly run options
- tests/PERFORMANCE_COMPARISON.md - Detailed benchmarks and comparisons
- Typical speeds: 3.6M rows/sec (flexible), 7.5M rows/sec (static), 127K rows/sec (1000 columns)
- Compression: 15-25% of CSV size (LZ4), 3-4% with Zero-Order Hold
Run benchmarks locally:
# Quick macro smoke run (default)
python3 benchmark/run.py wip
# Direct macro CLI overview (profiles/scenarios/examples)
build/ninja-release/bin/bench_macro_datasets --help
# Direct macro run with compact summary (narrow terminal friendly)
build/ninja-release/bin/bench_macro_datasets --size=S --summary=compact
# Micro benchmark pinned to CPU2
python3 benchmark/run.py wip --type=MICRO --pin=CPU2
# Combined campaign
python3 benchmark/run.py wip --type=MICRO,MACRO-SMALL,MACRO-LARGE
# Manual compare report (candidate vs baseline)
python3 benchmark/report.py <candidate_run_dir> --baseline <baseline_run_dir>14 dataset profiles ร multiple mode combinations (storage ร codec), with optional external CSV library comparison. See benchmark/README.md for details.
| Language | Integration | Best For | Guide |
|---|---|---|---|
| C++ | Header-only, C++20 | Maximum performance (static API) | examples/ |
| Python | pip install pybcsv |
Pandas workflows, prototyping | python/README.md |
| C# | dotnet add package Bcsv |
.NET services, Sampler, columnar I/O | csharp/README.md |
| Unity | UPM Git URL or tarball | Game development, recording | unity/README.md |
| C | Shared library (libbcsv) |
FFI bindings, embedded systems | docs/API_OVERVIEW.md |
All APIs produce identical binary format โ files are 100% cross-compatible. See docs/INTEROPERABILITY.md and docs/API_OVERVIEW.md for code examples and comparison matrix.
BCSV requires C++20 with full library support for <span>, <bit>, <concepts>, and <stop_token>.
| Platform | Compiler / Toolchain | Minimum Version | Notes |
|---|---|---|---|
| Linux x86/x64 | GCC | 13.1+ | -std=c++20 -pthread |
| Linux x86/x64 | Clang + libstdc++ | 16+ with libstdc++ 13+ | -std=c++20 -fbracket-depth=512 |
| Windows x64 | MSVC (Visual Studio) | VS 2022 17.4+ (MSVC 19.34+) | /std:c++20 /W4 |
| macOS x64/ARM | Apple Clang (Xcode) | Xcode 15.4+ | -std=c++20; Xcode 15.0โ15.3 lacks <stop_token> |
| macOS | Homebrew Clang/GCC | GCC 13+ or LLVM 17+ | Alternative to Apple Clang |
| STM32 (Linux) | Arm GNU Toolchain | GCC 13.2+ (CubeIDE 1.14+) | Embedded Linux on STM32MP1/MP2 |
| AMD/Xilinx (Linux) | Vitis / PetaLinux | 2024.1+ (GCC 13+) | Zynq, ZynqMP, Kria, Versal with Linux |
Build system: CMake โฅ 3.28, Ninja (recommended) or Make.
Embedded baremetal note: BCSV currently requires
std::fstreamfor I/O and uses C++ exceptions for logic errors. Baremetal/RTOS targets (STM32 F4/F7/H7, Zynq without Linux) lack filesystem and POSIX threading support, so BCSV does not build on baremetal without an I/O abstraction layer. See ARCHITECTURE.md for details.
Current Version: v1.5.8
- โ Streaming LZ4 compression with constant write latency
- โ
File indexing (
FileFooter) for O(log N) random access (ReaderDirectAccess) - โ
Delta + VLE row codec (
RowCodecDelta002) โ 2.3% of CSV size - โ Five file codec strategies (stream, stream-LZ4, packet, packet-LZ4, packet-LZ4-batch)
- โ Sampler API โ bytecode VM for row filtering and column projection
- โ
11 CLI tools including
bcsvSampler,bcsvGenerator,bcsvValidate,bcsvRepair,bcsvCast,bcsvCompare - โ Python (pybcsv) with pandas/Polars integration
- โ C# NuGet package with Sampler, CSV interop, columnar I/O
- โ Unity UPM package with native binaries
- โ Unified versioning (library = file format = packages)
- v2.0.0 (Q2 2026): Stable release with compatibility guarantees
bcsv/
โโโ include/bcsv/ # ๐ฆ Header-only library (copy this to integrate)
โ โโโ bcsv.h # Main include file
โ โโโ reader.hpp # Reader implementation
โ โโโ writer.hpp # Writer implementation
โ โโโ ... # Supporting headers
โ
โโโ docs/ # ๐ User-facing documentation
โ โโโ API_OVERVIEW.md # Multi-language API comparison
โ โโโ ERROR_HANDLING.md # Error handling guide
โ โโโ INTEROPERABILITY.md# Cross-language compatibility
โ
โโโ examples/ # ๐ฏ Usage examples (11 programs)
โ โโโ quickstart.cpp # Minimal 5-minute example
โ โโโ example.cpp # Basic flexible-layout usage
โ โโโ example_static.cpp # Static-layout usage
โ โโโ ... # delta, ZoH, direct access, error handling, sampler, visitor
โ
โโโ src/tools/ # ๐ง CLI tools (11 utilities)
โ โโโ csv2bcsv.cpp # CSV โ BCSV converter
โ โโโ bcsv2csv.cpp # BCSV โ CSV converter
โ โโโ bcsvSampler.cpp # Filter & project rows
โ โโโ ... # bcsvHead, bcsvTail, bcsvHeader, bcsvGenerator, bcsvValidate, bcsvRepair
โ
โโโ tests/ # โ
Comprehensive test suite (784 tests)
โโโ python/ # ๐ Python package (pip install pybcsv)
โโโ csharp/ # ๐ผ C# NuGet package (dotnet add package Bcsv)
โโโ unity/ # ๐ฎ Unity UPM integration
โโโ docs/ # ๐ Thread safety, error handling, interop, lean checklist
โโโ cmake/ # ๐ง Build system utilities
โ
โโโ ARCHITECTURE.md # ๐๏ธ Design and technical specification
โโโ VERSIONING.md # ๐ Version management
โโโ README.md # ๐ This file
Supports 12 types: BOOL, UINT8/16/32/64, INT8/16/32/64, FLOAT, DOUBLE, STRING
All types are stored in little-endian format with IEEE 754 for floating point. See docs/INTEROPERABILITY.md.
Bit-exactness guarantee: the binary format round-trips every IEEE-754 bit
pattern โ NaN (including payload bits), ยฑInf, signed zero (-0.0), and
subnormals โ through all row codecs (flat, ZoH, delta) on both the flexible
and static APIs. The CSV bridge (csv2bcsv/bcsv2csv, CsvWriter/CsvReader)
preserves special values (nan, inf, -inf, -0) but not NaN payload bits.
- Flexible (Runtime): Dynamic schemas, runtime validation, 3.6M rows/sec
- Static (Compile-Time): Type-safe templates, compile-time validation, 7.5M rows/sec
See docs/API_OVERVIEW.md for detailed comparison.
- I/O operations return
bool- check return value and usegetErrorMsg() - Row access throws exceptions - catch
std::out_of_rangeandstd::runtime_error
See docs/ERROR_HANDLING.md for complete guide.
Build and test:
# Configure and build
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
# Run tests
ctest --test-dir build --output-on-failure
# Try examples
./build/bin/example
./build/bin/csv2bcsv data.csvPython package:
cd python/
pip install -e . # Development modeCMake integration:
add_subdirectory(external/bcsv)
target_link_libraries(your_target PRIVATE bcsv)- LZ4 (v1.10.0) โ bundled in
include/lz4-1.10.0/ - xxHash (v0.8.3) โ bundled in
include/xxHash-0.8.3/ - C++20 Standard Library โ
<span>,<bit>,<concepts>,<stop_token>,<thread>,<fstream> - No external runtime dependencies โ header-only, copy
include/and compile
Build/test only:
- Google Test (auto-fetched via CMake FetchContent)
- nanobind (auto-fetched for Python bindings)
MIT License - Copyright (c) 2025 Tobias Weber. See LICENSE.
BCSV bundles third-party components under permissive BSD licenses โ LZ4 and xxHash (BSD-2-Clause) in the library, and CLI11 (BSD-3-Clause) in the CLI tools. Their copyright notices are reproduced in the LICENSE file.
Contributions welcome! Please open issues for bugs/features and include tests with PRs.
Ready to start? Check out examples/ or docs/API_OVERVIEW.md for detailed API documentation.