csv

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSV

type CSV struct {
	Header  []string
	Records [][]string
}

func Read

func Read(csvFile *os.File, flags CSVReaderFlag) (*CSV, error)

func (*CSV) BuildInputs

func (c *CSV) BuildInputs(inputNames map[string]string) ([]map[string]any, error)

BuildInputs is the same as BuildInputs, but it takes a schema to ensure that the input is valid. If the input is invalid, it will return an error. The function takes an action, as well as a map mapping the CSV column name to the action input name.

func (*CSV) ForEachRecord

func (c *CSV) ForEachRecord(fn func([]CSVCell) error) error

ForEachRecord will loop through each record in the CSV and call the function with the record as a map of the CSV column name to value.

func (*CSV) GetColumnIndex

func (c *CSV) GetColumnIndex(column string) int

GetColumnIndex returns the index of the column in the CSV. If the column doesn't exist, it will return -1.

type CSVCell

type CSVCell struct {
	Column *string
	Value  string
}

type CSVReaderFlag

type CSVReaderFlag uint8
const (
	ContainsHeader CSVReaderFlag = 1 << iota
)

Jump to

Keyboard shortcuts

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