Documentation
¶
Index ¶
- Constants
- func AutoAlignCsvArrays(csvArray1, csvArray2 [][]StringHashable) ([][]StringHashable, [][]StringHashable, error)
- func CheckForProperCsvArray(arr [][]StringHashable) error
- func Get2DArrayFrom2DArray(arr [][]string) [][]StringHashable
- func GetCommonIndices(arr1, arr2 [][]StringHashable, method int, sortIndices bool) ([]int, []int, error)
- func GetCommonRows(csvArray1, csvArray2 [][]StringHashable, options Options) ([][]StringHashable, [][]StringHashable, []int, []int, error)
- func GetDifferentIndices(arr1, arr2 [][]StringHashable, method int, sortIndices bool) ([]int, []int, error)
- func GetDifferentRows(csvArray1, csvArray2 [][]StringHashable, options Options) ([][]StringHashable, [][]StringHashable, []int, []int, error)
- func IgnoreColumns(arr [][]StringHashable, columns []StringHashable) ([][]StringHashable, error)
- func IgnoreRows(arr [][]StringHashable, rows []int) ([][]StringHashable, error)
- func KeepColumns(arr [][]StringHashable, columns []StringHashable) ([][]StringHashable, error)
- func KeepRows(arr [][]StringHashable, rows []int) ([][]StringHashable, error)
- func PrettyFormatCsvArray(csvArray [][]StringHashable, spaces int, maxColLength int) (string, error)
- func RearrangeColumns(arr [][]StringHashable, columns []StringHashable) ([][]StringHashable, error)
- func StringFormatCsvArray(csvArray [][]StringHashable) (string, error)
- type BasicStringHashable
- type Options
- type StringHashable
Constants ¶
const ( MethodMatch = iota MethodDirect MethodSet )
Supported comparison methods.
const TruncatedMark = ".."
For marking truncated pretty formatted strings.
Variables ¶
This section is empty.
Functions ¶
func AutoAlignCsvArrays ¶
func AutoAlignCsvArrays(csvArray1, csvArray2 [][]StringHashable) ([][]StringHashable, [][]StringHashable, error)
Automatically aligns the common columns on the left side. The relative positions of the common columns are the same as that of csvArray1 and uncommon columns are placed at the end with the same relative positions as that of the original arrays, respectively.
func CheckForProperCsvArray ¶
func CheckForProperCsvArray(arr [][]StringHashable) error
Returns nil iff the array is not empty, has no duplicate columns, and all rows have the same number elements.
func Get2DArrayFrom2DArray ¶
func Get2DArrayFrom2DArray(arr [][]string) [][]StringHashable
Returns a 2D array of StringHashable from a 2D array of strings.
func GetCommonIndices ¶
func GetCommonIndices(arr1, arr2 [][]StringHashable, method int, sortIndices bool) ([]int, []int, error)
Returns the indices of rows common to both arrays based on the method given.
func GetCommonRows ¶
func GetCommonRows(csvArray1, csvArray2 [][]StringHashable, options Options) ([][]StringHashable, [][]StringHashable, []int, []int, error)
Returns the common rows between the two arrays based on the given options and the indices of the rows in the results from the original arrays.
func GetDifferentIndices ¶
func GetDifferentIndices(arr1, arr2 [][]StringHashable, method int, sortIndices bool) ([]int, []int, error)
Returns the indices of rows that are different between the two arrays based on the method given.
func GetDifferentRows ¶
func GetDifferentRows(csvArray1, csvArray2 [][]StringHashable, options Options) ([][]StringHashable, [][]StringHashable, []int, []int, error)
Returns the different rows between the two arrays based on the given options and the indices of the rows in the results from the original arrays.
func IgnoreColumns ¶
func IgnoreColumns(arr [][]StringHashable, columns []StringHashable) ([][]StringHashable, error)
Returns a new csv array with the columns specified removed.
func IgnoreRows ¶
func IgnoreRows(arr [][]StringHashable, rows []int) ([][]StringHashable, error)
Returns a new 2D array with the rows specified removed.
func KeepColumns ¶
func KeepColumns(arr [][]StringHashable, columns []StringHashable) ([][]StringHashable, error)
Returns a new csv array with only the columns specified.
func KeepRows ¶
func KeepRows(arr [][]StringHashable, rows []int) ([][]StringHashable, error)
Returns a new 2D array with only the rows specified.
func PrettyFormatCsvArray ¶
func PrettyFormatCsvArray(csvArray [][]StringHashable, spaces int, maxColLength int) (string, error)
Takes a csv array and returns a columns-aligned formatted string according to spaces. Strings with lengths exceeding maxColLength are truncated. Use a negative value for maxColLength to keep strings of all lengths.
func RearrangeColumns ¶
func RearrangeColumns(arr [][]StringHashable, columns []StringHashable) ([][]StringHashable, error)
Returns a csv array with the columns rearranged accordingly.
func StringFormatCsvArray ¶
func StringFormatCsvArray(csvArray [][]StringHashable) (string, error)
Takes a csv array and returns a csv formatted string.
Types ¶
type BasicStringHashable ¶
type BasicStringHashable string
A basic implementation of the StringHashable interface for convenience.
func (BasicStringHashable) StringHash ¶
func (s BasicStringHashable) StringHash() string
type Options ¶
type Options struct {
Method int
UseColumns []StringHashable
IgnoreColumns []StringHashable
SortIndices bool
}
For holding supported options.
func (*Options) CheckAttributes ¶
Checks if the options are valid.
type StringHashable ¶
type StringHashable interface {
StringHash() string // This is used for equality comparison purposes.
}
For allowing different types to be used in the csv arrays.
func GetCommonColumns ¶
func GetCommonColumns(csvArray1, csvArray2 [][]StringHashable) ([]StringHashable, error)
Returns the common columns between the two csv arrays keeping the order of the relative positions of the columns in csvArray1.
func GetRowFromRow ¶
func GetRowFromRow(arr []string) []StringHashable
Returns a StringHashable row from a string row.