Documentation
¶
Overview ¶
Package tabular simplifies the reading of tabular data. It is especially intended for use when finding certain values in certain rows or columns, but can be useful for simply handling lists of strings.
Index ¶
- func AnySatisfies(pred StringPredicate, slice []string) bool
- func HasNonEmpty(slice []string) bool
- func IndiciesOf(needles []string, haystack string) (indicies []int)
- func Lines(str string) []string
- func ReIn(re *regexp.Regexp, slice []string) bool
- func SliceEqual(slc1 []string, slc2 []string) bool
- func StrContainedIn(str string, slice []string) bool
- func StrIn(str string, slice []string) bool
- func TableEqual(t1 Table, t2 Table) bool
- func ToString(table Table) string
- func Unlines(slc []string) string
- type Column
- type Row
- type StringPredicate
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnySatisfies ¶
func AnySatisfies(pred StringPredicate, slice []string) bool
AnySatisfies checks to see whether any string in a given slice satisfies the provided StringPredicate.
func HasNonEmpty ¶ added in v0.2.2
HasNonEmpty checks to see if there is a single string with a non-whitespace character in the list
func IndiciesOf ¶ added in v0.2.2
IndiciesOf takes a list of needles and a haystack and returns the first locations of all the needles
func SliceEqual ¶ added in v0.2.2
func StrContainedIn ¶
StrContainedIn works like strIn, but checks for substring containing rather than whole string equality.
func TableEqual ¶ added in v0.2.2
TableEqual tests the equality of the tables by examining each cell
Types ¶
type Column ¶
type Column []string
Column is a slice of strings, a vertical slice of a Table.
func GetColumn ¶
GetColumn isolates the entries of a single column from a 2D slice, specified by the column number (counting from zero on the left).
func GetColumnByHeader ¶
GetColumnByHeader returns the body of a column with a header that is equal to name (ignoring case differences). It is for developer ease and future-proofing, as it doesn't rely on an index.
func GetColumnNoHeader ¶
GetColumnNoHeader safely removes the first element from a column.
type StringPredicate ¶
StringPredicate is a function that filters a list of strings
type Table ¶
type Table [][]string
Table is a 2D slice of strings, for representing tabular data as cells, in rows and columns.
func ProbabalisticSplit ¶
ProbabalisticSplit splits a string based on the regexp that gives the most consistent line length (potentially discarding one outlier line length).
func SeparateOnAlignment ¶ added in v0.2.2
SeparateOnAlignment splits a table based on the indicies of its headers, assuming all columns are left-aligned and all headers are separated by whitespace
func SeparateString ¶
SeparateString is an abstraction of stringToSlice that takes two kinds of separators, and splits a string into a 2D slice based on those separators
func StringToSlice ¶
StringToSlice takes in a string and returns a 2D slice of its output, separated on whitespace and newlines TODO: this should be depreciated by probabalisticSplit