csv

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package csv provides CSV reading and writing for the dataset package.

This is a pure API facade — it contains zero heavy imports. The actual CSV parsing/writing is delegated to the engine via the dataset.CSVReader and dataset.CSVWriter interfaces:

  • Memory engine: uses go-simdcsv + schema inference (dataset/memory/csv.go)
  • Arrow engine: uses arrow/csv for zero-copy ingest (dataset/arrow/csv.go)

Usage:

ds, err := csv.Read(ctx, file, eng, csv.WithHeader(true))
err = csv.Write(ctx, file, ds, eng)

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedType = errors.New("csv: unsupported column type")

ErrUnsupportedType is returned for unsupported column types.

Functions

func Read

func Read(ctx context.Context, r io.Reader, eng dataset.Engine, opts ...Option) (dataset.Dataset, error)

Read reads a CSV from r using the given engine. The engine must have a registered CSVReader.

func Write

func Write(ctx context.Context, w io.Writer, ds dataset.Dataset, eng dataset.Engine, opts ...Option) error

Write writes a Dataset as CSV to w using the given engine. The engine must have a registered CSVWriter.

Types

type Option

type Option func(*dataset.CSVConfig)

Option is a functional option for CSV read/write.

func WithChunk

func WithChunk(n int) Option

WithChunk sets the number of rows per batch during reading. 0 means engine default (arrow: 65536, memory: unlimited).

func WithComma

func WithComma(r rune) Option

WithComma sets the field delimiter. Default is ','.

func WithComment

func WithComment(r rune) Option

WithComment sets the comment character.

func WithHeader

func WithHeader(v bool) Option

WithHeader enables CSV header parsing (first row = column names).

func WithNullValues

func WithNullValues(vals ...string) Option

WithNullValues sets strings to treat as null.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL