Files
obitools4/autodoc/docmd/pkg/obitools/obicsv/writer.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

1.3 KiB

CSV Export Functionality in obicsv Package

The obicsv package provides utilities for efficiently writing structured data (e.g., sequence annotations) to CSV format, supporting parallel processing and streaming.

  • FormatCVSBatch(): Converts a batch of CSV records (CSVRecordBatch) into an in-memory buffer, using the provided header and a placeholder for missing values (navalue). It prepends the header only once (for batch order 0).

  • WriteCSV(): Writes a CSV-formatted stream from an ICSVRecord iterator to any io.WriteCloser. It supports:

    • Compression (via obiutils.CompressStream)
    • Parallel workers for batch processing (ParallelWorkers())
    • Chunked writing via obiformats.WriteFileChunk
  • WriteCSVToStdout() / WriteCSVToFile(): Convenience wrappers:

    • Outputs to stdout (os.Stdout)
    • Writes to a file (with O_WRONLY, optional append/truncate)
  • Key design features:

    • Non-blocking, concurrent processing using goroutines
    • Graceful shutdown via WaitAndClose() and channel signaling
    • Robust handling of missing/invalid values (falls back to navalue)
  • Dependencies: Leverages internal packages for iteration (obiitercsv), data formats (obiformats), and utilities (obiutils, logrus logging).