table

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ExcelMaxColCount = 16384
	ExcelMaxRowCount = 1048576
	Alphabet         = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	ZZ               = uint32(702)
	ZZIndex          = uint32(701)
)
View Source
const StyleSimple = "border:1px solid #000;border-collapse:collapse"

Variables

View Source
var DebugReadCSV = false // should not need to use this.

Functions

func ColIndexToLetters

func ColIndexToLetters(colIndex uint32) string

func ColNumberToLetters

func ColNumberToLetters(colNumber uint32) string

func CoordinateNumbersToSheetLocation

func CoordinateNumbersToSheetLocation(colNum, rowNum uint32) string

CoordinateNumbersToSheetLocation converts x, y integer coordinates to a spreadsheet location such as "AA1" for col 27, row 1.

func CoordinatesToSheetLocation

func CoordinatesToSheetLocation(colIdx, rowIdx uint32) string

CoordinatesToSheetLocation converts x, y integer coordinates to a spreadsheet location such as "AA1" for col 27, row 1.

func FormatStringAndFloats

func FormatStringAndFloats(val string, colIdx uint) (interface{}, error)

func FormatStringAndInts

func FormatStringAndInts(val string, colIdx uint) (interface{}, error)

func FormatStrings

func FormatStrings(val string, col uint) (interface{}, error)

func FormatTimeAndFloats

func FormatTimeAndFloats(val string, colIdx uint) (interface{}, error)

func FormatTimeAndInts

func FormatTimeAndInts(val string, colIdx uint) (interface{}, error)

func MergeFilterCSVFilesToJSON

func MergeFilterCSVFilesToJSON(inPaths []string, outPath string, inComma rune, inStripBom bool, perm os.FileMode, andFilter map[string]stringsutil.MatchInfo) error

func ReadCSVFileSingleColumnValuesString

func ReadCSVFileSingleColumnValuesString(filename, sep string, hasHeader, trimSpace bool, col uint, condenseUniqueSort bool) ([]string, error)

func ReadCSVFilesSingleColumnValuesString

func ReadCSVFilesSingleColumnValuesString(files []string, sep string, hasHeader, trimSpace bool, col uint, condenseUniqueSort bool) ([]string, error)

func SimpleTable

func SimpleTable(table Table) string

func StreamSimpleTable

func StreamSimpleTable(qw422016 *qt422016.Writer, table Table)

func ToDocuments

func ToDocuments(tbl *Table) []map[string]interface{}

func ToHTML

func ToHTML(tbl *Table, escapeHTML bool) string

ToHTML converts `*TableData` to HTML.

func WriteCSV

func WriteCSV(path string, t *Table) error

WriteCSV writes the table as a CSV.

func WriteCSVSimple

func WriteCSVSimple(cols []string, records [][]string, filename string) error

WriteCSVSimple writes a file with cols and records data.

func WriteSimpleTable

func WriteSimpleTable(qq422016 qtio422016.Writer, table Table)

func WriteXLSX

func WriteXLSX(path string, tbls ...*Table) error

WriteXLSX writes a table as an Excel XLSX file with row formatter option.

func WriteXLSXInterface

func WriteXLSXInterface(filename string, sheetdatas ...SheetData) error

Types

type DocumentsSet

type DocumentsSet struct {
	Meta      DocumentsSetMeta    `json:"meta"`
	Documents []map[string]string `json:"records"`
}

func NewDocumentsSet

func NewDocumentsSet() DocumentsSet

func ReadMergeFilterCSVFiles

func ReadMergeFilterCSVFiles(inPaths []string, outPath string, inComma rune, inStripBom bool, andFilter map[string]stringsutil.MatchInfo) (DocumentsSet, error)

func (*DocumentsSet) CreateHistogram

func (ds *DocumentsSet) CreateHistogram(key string)

func (*DocumentsSet) Inflate

func (ds *DocumentsSet) Inflate()

type DocumentsSetMeta

type DocumentsSetMeta struct {
	Count      int                            `json:"count"`
	Histograms map[string]histogram.Histogram `json:"histograms"`
}

func NewDocumentsSetMeta

func NewDocumentsSetMeta() DocumentsSetMeta

type SheetData

type SheetData struct {
	SheetName string
	Rows      [][]interface{}
}

type Table

type Table struct {
	Name       string
	Columns    []string
	Records    [][]string
	FormatMap  map[int]string
	FormatFunc func(val string, colIdx uint) (interface{}, error)
	ID         string
	Class      string
	Style      string
}

Table is useful for working on CSV data

func NewTable

func NewTable() Table

func NewTableFileSimple

func NewTableFileSimple(path string, sep string, hasHeader, trimSpace bool) (Table, error)

func NewTableFilesSimple

func NewTableFilesSimple(filenames []string, sep string, hasHeader, trimSpace bool) (Table, error)

func ReadFile

func ReadFile(path string, comma rune, stripBom bool) (Table, error)

ReadFile reads in a delimited file and returns a `Table` struct.

func (*Table) ColIndex added in v1.2.0

func (t *Table) ColIndex(colName string) int

func (*Table) ColValuesByColName added in v1.2.0

func (t *Table) ColValuesByColName(colName string) ([]string, error)

func (*Table) ColumnIndex

func (t *Table) ColumnIndex(wantCol string) int

func (*Table) ColumnValuesDistinct

func (t *Table) ColumnValuesDistinct(wantCol string) (map[string]int, error)

func (*Table) ColumnValuesMinMax

func (t *Table) ColumnValuesMinMax(wantCol string) (string, string, error)

func (*Table) ColumnsValuesDistinct

func (t *Table) ColumnsValuesDistinct(wantCols []string, stripSpace bool) (map[string]int, error)

func (*Table) FilterRecords added in v1.2.0

func (t *Table) FilterRecords(wantColNameValues map[string]string) ([][]string, error)

func (*Table) FormatterFunc

func (tbl *Table) FormatterFunc() func(val string, colIdx uint) (interface{}, error)

func (*Table) LoadMergedRows

func (t *Table) LoadMergedRows(data [][]string)

LoadMergedRows is used to load data from `[][]string` sources like csv.ReadAll()

func (*Table) NewTableFiltered added in v1.2.0

func (t *Table) NewTableFiltered(wantColNameValues map[string]string) (Table, error)

func (*Table) RecordToMSS

func (t *Table) RecordToMSS(record []string) map[string]string

func (*Table) RecordValue

func (t *Table) RecordValue(wantCol string, record []string) (string, error)

func (*Table) RecordValueOrEmpty

func (t *Table) RecordValueOrEmpty(wantCol string, record []string) string

func (*Table) ToSliceMSS

func (t *Table) ToSliceMSS() []map[string]string

func (*Table) WriteCSV

func (t *Table) WriteCSV(path string) error

func (*Table) WriteJSON

func (t *Table) WriteJSON(path string, perm os.FileMode, jsonPrefix, jsonIndent string) error

func (*Table) WriteXLSX

func (t *Table) WriteXLSX(path, sheetname string) error

type TableSet

type TableSet struct {
	Columns      []string
	RowFormatter func(val string, col uint) (interface{}, error)
	TableMap     map[string]*Table
}

func (*TableSet) AddRecord

func (ts *TableSet) AddRecord(tableName string, row []string)

func (*TableSet) TableNames

func (ts *TableSet) TableNames() []string

func (*TableSet) TablesSorted

func (ts *TableSet) TablesSorted() []*Table

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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