csv

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package csv provides CSV reading and writing functionality for DataFrames.

Features:

  • Automatic type inference (int64, float64, bool, string)
  • Configurable NA value detection
  • Support for custom delimiters
  • Header row handling
  • Streaming support for large files (phase 5)

Performance targets:

  • Phase 1: >500MB/s baseline reading on NVMe SSD
  • Phase 5: >2GB/s with parallel chunks and SIMD optimizations

Example:

df, err := csv.ReadCSV("data.csv",
    csv.WithDelimiter(','),
    csv.WithHeader(true),
    csv.WithNA([]string{"NA", "NULL"}),
)

err = csv.WriteCSV(df, "output.csv")

Package csv provides CSV reading and writing functionality for DataFrames.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadCSV

func ReadCSV(path string, opts ...CSVOption) (*dataframe.DataFrame, error)

ReadCSV reads a CSV file and returns a DataFrame.

func ReadCSVToSeries

func ReadCSVToSeries(path string, colName string, opts ...CSVOption) (*series.Series[any], error)

ReadCSVToSeries reads a single column from a CSV file as a Series.

func ToCSV

func ToCSV(df *dataframe.DataFrame, path string) error

ToCSV is a convenience method for writing a DataFrame to CSV.

func WriteCSV

func WriteCSV(df *dataframe.DataFrame, path string, opts ...CSVOption) error

WriteCSV writes a DataFrame to a CSV file.

Types

type CSVOption

type CSVOption func(*CSVReader) error

CSVOption is a functional option for configuring CSVReader.

func WithChunkSize

func WithChunkSize(size int) CSVOption

WithChunkSize sets the chunk size for reading large files.

func WithDelimiter

func WithDelimiter(delim rune) CSVOption

WithDelimiter sets the field delimiter (default: comma).

func WithDtypes

func WithDtypes(dtypes map[string]core.Dtype) CSVOption

WithDtypes sets explicit data types for columns.

func WithHeader

func WithHeader(header bool) CSVOption

WithHeader specifies if the first row contains column names (default: true).

func WithNA

func WithNA(naValues []string) CSVOption

WithNA sets the list of strings to treat as null values.

func WithNAValue

func WithNAValue(naValue string) CSVOption

WithNAValue sets the string to use for null values when writing.

func WithParallel

func WithParallel(n int) CSVOption

WithParallel sets the number of parallel workers (default: runtime.NumCPU()).

func WithWriteDelimiter

func WithWriteDelimiter(delim rune) CSVOption

WithWriteDelimiter sets the field delimiter for writing.

func WithWriteHeader

func WithWriteHeader(header bool) CSVOption

WithWriteHeader specifies whether to write column names as the first row.

type CSVReader

type CSVReader struct {
	// contains filtered or unexported fields
}

CSVReader reads CSV files into DataFrames.

type CSVWriter

type CSVWriter struct {
	// contains filtered or unexported fields
}

CSVWriter writes DataFrames to CSV files.

Jump to

Keyboard shortcuts

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