kut

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 3 Imported by: 0

README

kut

Docs Tests Report Card

$ kut -h
Usage: kut [OPTION] LIST

kut is a cut command for CSV (RFC 4180) input. kut reads from standard input
and writes to standard output.

LIST is a list of ranges separated by commas, using the same rules as cut(1).

Options:
  -d, --delimiter=DELIM    Use DELIM as field delimiters instead of commas.
  -h, --help               Show this help message.

Why

cut(1) isn't sufficient for certain CSV files. There are some other tools that solve this problem, but kut

  • has no dependencies
  • has a simple interface
  • only does one thing
  • is a statically linked executable

How

go install github.com/jalan/kut/cmd/kut

Documentation

Overview

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

Index

Constants

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

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

Variables

This section is empty.

Functions

This section is empty.

Types

type ColRange

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

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

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

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

func (*Cutter) Delimiter

func (c *Cutter) Delimiter() rune

Delimiter returns the field delimiter.

func (*Cutter) Scan

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

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 io.EOF, it does not report io.EOF as an error.

func (*Cutter) SetDelimiter

func (c *Cutter) SetDelimiter(d rune)

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

Directories

Path Synopsis
cmd
kut

Jump to

Keyboard shortcuts

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