kut: github.com/jalan/kut Index | Files | Directories

package kut

import "github.com/jalan/kut"

Package kut provides column cutting for CSV (RFC 4180) files.

Index

Package Files

cutter.go

Constants

const EOL = int(^uint(0) >> 1)

EOL can be used as the End in a ColRange to include all remaining columns.

type ColRange Uses

type ColRange struct {
    Start int
    End   int
}

A ColRange specifies a range of columns to include. Column numbers begin at 1. Both Start and End are inclusive.

type Cutter Uses

type Cutter struct {
    Ranges []ColRange
    // contains filtered or unexported fields
}

A Cutter reads from an input CSV and writes only the specified columns to an output CSV.

func NewCutter Uses

func NewCutter(r io.Reader, w io.Writer) *Cutter

NewCutter returns a Cutter that reads from r and writes to w.

func (*Cutter) Delimiter Uses

func (c *Cutter) Delimiter() rune

Delimiter returns the field delimiter.

func (*Cutter) Scan Uses

func (c *Cutter) Scan() error

Scan advances one record on the input, outputting only the columns specified in Ranges. If there is no input left to read, Scan returns io.EOF.

func (*Cutter) ScanAll Uses

func (c *Cutter) ScanAll() error

ScanAll advances to the end of the input, outputting only the columns specified in Ranges. Because ScanAll deliberately reads until EOF, it does not report EOF as an error.

func (*Cutter) SetDelimiter Uses

func (c *Cutter) SetDelimiter(d rune)

SetDelimiter sets the field delimiter, which defaults to a comma.

Directories

PathSynopsis
cmd/kut

Package kut imports 3 packages (graph) and is imported by 1 packages. Updated 2019-01-10. Refresh now. Tools for package owners.