table

package
v0.0.0-...-2c14cb9 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

The table package implements a simplistic 2-dimensional array that can be populated one cell at a time, and output as a CSV. It is intended to be used to build up a wide table from results of queries on the geo_metric table.

So input that looks like this:

	HERE	COLA	10
 HERE	COLB	20
	THERE	COLA	30
	THERE	COLB	40

Becomes

 GEO		COLA	COLB
	HERE	10		20
	THERE	30		40

Index

Constants

View Source
const (
	ColGeographyCode = "geography_code"
	ColGeotype       = "geotype"
	ColGeocodes      = "geocode" // XXX temporary
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Catcode

type Catcode string // eg "QS412EW0001"

type Geocode

type Geocode string // eg "E07000107"

type Geotype

type Geotype string // eg "LSOA", "LAD", ...

type Table

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

func New

func New() *Table

New creates a new table.

func (*Table) Generate

func (tbl *Table) Generate(w io.Writer, include []string) error

Generate produces a CSV version of the table on w. It doesn't close w.

include is a list of non-category columns to include in the output table. Currently supported values are "geography_code" and "geotype".

func (*Table) SetCell

func (tbl *Table) SetCell(geocode, geotype, catcode string, value float64)

SetCell sets the value of a cell on the row matching geocode and geotype, and the column matching colname. New rows and columns are created dynamically. XXX check for duplicate geotype XXX move errors.go to its own pkg/errors

Jump to

Keyboard shortcuts

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