csvsrc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package csvsrc opens CSV files for repeated, seekable reads.

A Source hides three details from the rest of the program: where the bytes live (a file on disk or a buffer in memory), what encoding they arrived in, and which delimiter separates the fields. Everything downstream just asks for a *csv.Reader positioned at a byte offset.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoding

type Encoding string

Encoding names the character encoding detected in a source.

const (
	UTF8    Encoding = "utf-8"
	UTF16LE Encoding = "utf-16le"
	UTF16BE Encoding = "utf-16be"
	Latin1  Encoding = "latin-1"
)

type Source

type Source struct {
	Name      string // display name ("-" becomes "<stdin>")
	Delimiter rune
	Encoding  Encoding
	// contains filtered or unexported fields
}

Source is an opened CSV input. Reads are cheap and repeatable: the file path is reopened per read for on-disk sources, so many readers can be live at once without sharing a file position.

func Open

func Open(path string, delim rune) (*Source, error)

Open reads enough of path to work out its encoding and delimiter. A path of "-" reads standard input into memory. A non-zero delim skips delimiter detection.

func (*Source) DelimiterName

func (s *Source) DelimiterName() string

DelimiterName gives a human name for the delimiter, for status lines.

func (*Source) Reader

func (s *Source) Reader(off int64) (*csv.Reader, func() error, error)

Reader returns a *csv.Reader positioned at off, a byte offset in decoded space as reported by (*csv.Reader).InputOffset. Callers must call the returned close func.

Jump to

Keyboard shortcuts

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