csv

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	// These are pointers because not every column will define a value for them
	NumericConstraint   *faker.NumericConstraint   `yaml:"numericConstraint"`
	StringConstraint    *faker.StringConstraint    `yaml:"stringConstraint"`
	TimestampConstraint *faker.TimestampConstraint `yaml:"timestampConstraint"`
	GeneralConstraint   *faker.GeneralConstraint   `yaml:"generalConstraint"`

	Order *int `yaml:"order"`

	// These are required by every column
	Label  string `yaml:"label"`
	Source string `yaml:"source"`
}

func (*Column) Validate

func (c *Column) Validate() error

type File

type File struct {
	Headers     []Column
	Rows        []Row
	RecordCount int
	Delimiter   rune
}

func New

func New(headers []Column, rowCount int, delimiter rune) *File

func (*File) AddRow

func (f *File) AddRow()

func (*File) AddRowAtIndex

func (ef *File) AddRowAtIndex(i int) error

func (*File) Corrupt

func (ef *File) Corrupt(chance float64) error

func (*File) Write

func (f *File) Write(filename string) error

type Headers

type Headers []Column

func (Headers) Sort

func (h Headers) Sort() Headers

func (Headers) Validate

func (h Headers) Validate() error

type Row

type Row struct {
	// Values is a map of column labels to column values. This must be a
	// map to ensure the CSV output matches values to the correct
	// column.
	Values map[string]string
}

func NewRow

func NewRow(headers []Column) Row

func (*Row) ToStringSlice

func (r *Row) ToStringSlice(headers []Column) []string

Jump to

Keyboard shortcuts

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