decoding

package
v0.0.0-...-a0cf6f9 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package decoding handles decoding of CSV, TSV, JSON, and fixed length text.

Package decoding handles decoding of CSV, TSV, JSON, and fixed length text.

Package decoding handles decoding of CSV, TSV, JSON, and fixed length text.

Package decoding handles decoding of CSV, TSV, JSON, and fixed length text.

Package decoding handles decoding of CSV, TSV, JSON, and fixed length text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvDecoderOptions

type CsvDecoderOptions struct {
	// Charset is an input character encoding (default: charset.UTF8)
	Charset charset.Charset
	// Charset default: ','
	Separator rune
	// Header
	// If none specified: 1st line is header, 2nd and later lines are data
	// If one or more are specified: everything after the first line is data
	Header []string
	// HeaderAliases
	// Convert values obtained as headers (either explicitly in Header or from the first line of io.Reader) before they are actually processed by csvutil's CSV decoder.
	HeaderAliases map[string]string
}

CsvDecoderOptions is an optional argument to NewCsvDecoder.

type Decoder

type Decoder[TRow any] interface {
	Decode() (TRow, error)
}

Decoder handles decoding of CSV, TSV, JSON, and fixed length text.

func NewCsvDecoder

func NewCsvDecoder[TRow any](src io.Reader, opts CsvDecoderOptions) Decoder[TRow]

NewCsvDecoder creates a Decoder that processes CSV/TSV. See csvutil documentation for structure tags: https://github.com/jszwec/csvutil

func NewFixedWidthDecoder

func NewFixedWidthDecoder[TRow any](src io.Reader, opts FixedWidthDecoderOptions) Decoder[TRow]

NewFixedWidthDecoder creates a Decoder that processes fixed length fields. See the fixedwidth documentation for the structure tags: https://github.com/ianlopshire/go-fixedwidth

func NewJSONDecoder

func NewJSONDecoder[TRow any](src io.Reader) Decoder[TRow]

NewJSONDecoder creates a decoder that processes JSON. Note: This is not row-oriented JSONL, but JSON with an array directly under the root.

func NewJSONLDecoder

func NewJSONLDecoder[TRow any](src io.Reader) Decoder[TRow]

NewJSONLDecoder creates a decoder that processes JSONL. Note: It assumes row-oriented JSONL, not JSON with an array directly under the root.

type FixedWidthDecoderOptions

type FixedWidthDecoderOptions struct {
	// Charset is an input character encoding (default: charset.UTF8)
	Charset charset.Charset
}

Directories

Path Synopsis
Package adjuster provides a mechanism to relax the requirement for the number of CSV fields.
Package adjuster provides a mechanism to relax the requirement for the number of CSV fields.
Package buffering provides a mechanism for peeking at CSV header lines.
Package buffering provides a mechanism for peeking at CSV header lines.

Jump to

Keyboard shortcuts

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