internal

package
v0.0.0-...-569648f Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRLF = "\n"
)

Variables

View Source
var (
	FlagNoHeader    bool
	FlagSeparator   string
	FlagUseTestData bool
	FlagDebug       bool
)

Functions

func CSVSliceToString

func CSVSliceToString(slice [][]string) string

CSVSliceToString converts a csv [][]string to a string

func CheckIfErrorAndPanic

func CheckIfErrorAndPanic(err error)

CheckIfErrorAndPanic should be used to naively panics if an error is not nil.

func Difference

func Difference(a, b []string) []string

Difference returns the elements in `a` that aren't in `b`.

func ReadFromStdIn

func ReadFromStdIn() string

ReadFromStdIn reads piped data from std in

Types

type CSVField

type CSVField = map[string]string

CSVField represents a column name to value map

type CSVObject

type CSVObject struct {
	Headers []string
	Rows    []CSVRow
	// contains filtered or unexported fields
}

CSVObject is a list of csv rows

func ParseCSV

func ParseCSV(data string, hasHeader bool) *CSVObject

ParseCSV parses the given string as CSV object

func ReadCSV

func ReadCSV() *CSVObject

ReadCSV reads the csv from stdin or returns test data if the test flag is set

func (*CSVObject) FilterColumns

func (c *CSVObject) FilterColumns(fields []string) *CSVObject

FilterColumns retains only the given fields

func (*CSVObject) Flatten

func (c *CSVObject) Flatten(separator string) (string, error)

Flatten flattens the csv into a one liner

func (*CSVObject) Print

func (c *CSVObject) Print()

Print prints the csv to stdout

func (*CSVObject) String

func (c *CSVObject) String() string

String converts the csv object to string representation

type CSVRow

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

CSVRow is a column name to value map and a pointer to the csv object

func (*CSVRow) Get

func (c *CSVRow) Get(field string) (string, error)

Get returns the value of the given field

Jump to

Keyboard shortcuts

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