parseutils

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapCSVHeaders

func MapCSVHeaders(headers []string, fields []string) (map[string]any, error)

MapCSVHeaders creates a map of headers[i] -> fields[i].

func ParseKeyValuePairs

func ParseKeyValuePairs(pairs []string, delimiter string) (map[string]any, error)

ParseKeyValuePairs will split each string in `pairs` on the `delimiter` into a key and value string that get added to a map and returned.

func ReadCSVRow

func ReadCSVRow(row string, delimiter rune, lazyQuotes bool) ([]string, error)

ReadCSVRow reads a CSV row from the csv reader, returning the fields parsed from the line. We make the assumption that the payload we are reading is a single row, so we allow newline characters in fields. However, the csv package does not support newlines in a CSV field (it assumes rows are newline separated), so in order to support parsing newlines in a field, we need to stitch together the results of multiple Read calls.

func SplitString

func SplitString(input, delimiter string) ([]string, error)

SplitString will split the input on the delimiter and return the resulting slice while respecting quotes. Outer quotes are stripped. Use in place of `strings.Split` when quotes need to be respected. Requires `delimiter` not be an empty string

Types

This section is empty.

Jump to

Keyboard shortcuts

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