write

package
v0.0.0-...-f1fddf1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CsvToProtocolLines

func CsvToProtocolLines(reader io.Reader) io.Reader

CsvToProtocolLines transforms csv data into line protocol data

func IsTypeSupported

func IsTypeSupported(dataType string) bool

IsTypeSupported returns true if the data type is supported

Types

type CsvColumnError

type CsvColumnError struct {
	Column string
	Err    error
}

CsvColumnError indicates conversion in a specific column

func (CsvColumnError) Error

func (e CsvColumnError) Error() string

type CsvLineError

type CsvLineError struct {
	Line int
	Err  error
}

CsvLineError is returned for csv conversion errors Line numbers are 1-indexed

func (CsvLineError) Error

func (e CsvLineError) Error() string

type CsvTable

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

CsvTable gathers metadata about columns

func (*CsvTable) AddRow

func (t *CsvTable) AddRow(row []string) bool

AddRow adds header, comment or data row

func (*CsvTable) AppendLine

func (t *CsvTable) AppendLine(buffer []byte, row []string) ([]byte, error)

AppendLine appends a protocol line to the supplied buffer and returns appended buffer and error indication

func (*CsvTable) Column

func (t *CsvTable) Column(label string) *CsvTableColumn

Column returns the first column of the supplied label or nil

func (*CsvTable) Columns

func (t *CsvTable) Columns() []CsvTableColumn

Columns returns available columns

func (*CsvTable) CreateLine

func (t *CsvTable) CreateLine(row []string) (line string, err error)

CreateLine produces a protocol line of the supplied row or returned error

func (*CsvTable) FieldName

func (t *CsvTable) FieldName() *CsvTableColumn

FieldName returns field name column or nil

func (*CsvTable) FieldValue

func (t *CsvTable) FieldValue() *CsvTableColumn

FieldValue returns field value column or nil

func (*CsvTable) Fields

func (t *CsvTable) Fields() []CsvTableColumn

Fields returns fields

func (*CsvTable) Measurement

func (t *CsvTable) Measurement() *CsvTableColumn

Measurement returns measurement column or nil

func (*CsvTable) Tags

func (t *CsvTable) Tags() []CsvTableColumn

Tags returns tags

func (*CsvTable) Time

func (t *CsvTable) Time() *CsvTableColumn

Time returns time column or nil

type CsvTableColumn

type CsvTableColumn struct {
	// label such as "_start", "_stop", "_time"
	Label string
	// "string", "long", "dateTime:RFC3339" ...
	DataType string
	// column's line part (0 means not determined), see linePart constants
	LinePart int
	// default value to be used for rows where value is an empty string.
	DefaultValue string
	// index of this column in the table row
	Index int
	// contains filtered or unexported fields
}

CsvTableColumn represents metadata of a csv column

func (*CsvTableColumn) LineLabel

func (c *CsvTableColumn) LineLabel() string

LineLabel returns escaped column name so that it can be used as tag name or field name in line protocol

Jump to

Keyboard shortcuts

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