Help us shape the future of Go! Take the 2026 Go Developer Survey

wtrcsv

package module
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: ISC Imports: 8 Imported by: 0

README

go-wtrcsv

Go package to read/filter/write an OFCOM WTR CSV data dump.

The test data is omitted as this is ~100MB and can be downloaded from the OFCOM web site.

This code worked with the OFCOM WTR CSV as of 7 Feb 2018.

Documentation

Index

Constants

View Source
const (
	HeadingOsEasting      = "OS Easting"
	HeadingOsNorthing     = "OS Northing"
	HeadingWgs84Longitude = "WGS84 Longitude"
	HeadingWgs84Latitude  = "WGS84 Latitude"
)

Variables

This section is empty.

Functions

func CSVToMap

func CSVToMap(reader io.Reader) ([]string, []map[string]string)

CSVToMap takes a reader and returns a slice of maps. Uses the header row as the keys. From a Gist on GitHub

func FilterCompanies

func FilterCompanies(companies ...string) func(*Row) bool

func FilterNumericalProductCodes

func FilterNumericalProductCodes(numericalProductCodes ...string) func(*Row) bool

FilterNumericalProductCodes returns a function with the FilterFn signature. The returned function returns true if a Row numerical product code matches any numerical product code in numericalProductCodes.

func FilterPointToPoint

func FilterPointToPoint(row *Row) bool

FilterPointToPoint is a specialised version of FilterNumericalProductCodes that omits the intermediate FilterFn function.

func FilterValidNGR

func FilterValidNGR(row *Row) bool

FilterValidNGR ensures that there is a valid NGR

func GetProductCodeLookup

func GetProductCodeLookup() map[string]string

GetProductCodeLookup returns a map of numerical product code vs product description (not OFCOM's verbatim).

Types

type Collection

type Collection struct {
	Header []string
	Rows   []*Row
}

func ReadCSV added in v0.0.19

func ReadCSV(reader io.Reader) *Collection

ReadCSV to read in the OFCOM WTR csv.

func (*Collection) Filter

func (collection *Collection) Filter(filterFuncs ...FilterFn) *Collection

Filter returns a filtered Collection. Every filterFunc is called on each Row in Collection. Every filterFunc has to return true for the Row to be added to the filtered Collection.

func (*Collection) FilterInPlace

func (collection *Collection) FilterInPlace(filterFuncs ...FilterFn) *Collection

FilterInPlace is as Filter but overwrites the original backing array with the filtered.

func (*Collection) GetCompanies

func (collection *Collection) GetCompanies() []string

GetCompanies returns a slice of strings of unique Company names from all the licence rows in the licence collection.

func (*Collection) WriteCSV added in v0.0.19

func (collection *Collection) WriteCSV(writer io.Writer)

WriteCSV writes the csv header, then writes the rows.

type FilterFn

type FilterFn func(row *Row) bool

type Row

type Row struct {
	LicenceNumber          string
	LicenceIssueDate       string
	SidLatNS               string
	SidLatDeg              string
	SidLatMin              string
	SidLatSec              string
	SidLongEW              string
	SidLongDeg             string
	SidLongMin             string
	SidLongSec             string
	NGR                    string
	Frequency              string
	FrequencyType          string
	StationType            string
	ChannelWidth           string
	ChannelWidthType       string
	HeightAboveSeaLevel    string
	AntennaErp             string
	AntennaErpType         string
	AntennaType            string
	AntennaGain            string
	AntennaAzimuth         string
	HorizontalElements     string
	VerticalElements       string
	AntennaHeight          string // Resolution to 0.5m
	AntennaLocation        string
	EflUpperLower          string
	AntennaDirection       string
	AntennaElevation       string
	AntennaPolarisation    string
	AntennaName            string
	FeedingLoss            string
	FadeMargin             string
	EmissionCode           string
	ApCommentIntern        string
	Vector                 string
	LicenseeSurname        string
	LicenseeFirstName      string
	LicenseeCompany        string
	Status                 string
	Tradeable              string
	Publishable            string
	ProductCode            string
	ProductDescription     string
	ProductDescription31   string
	ProductDescription32   string
	Wgs84LongitudeAsString string // Persistent representation
	Wgs84LatitudeAsString  string
	Wgs84Longitude         float64 // Converted from persistent
	Wgs84Latitude          float64
	OsEasting              int
	OsNorthing             int
}

func (*Row) AntennaHeightAsFloat

func (row *Row) AntennaHeightAsFloat() float64

func (*Row) FrequencyAsFloat

func (row *Row) FrequencyAsFloat() float64

Jump to

Keyboard shortcuts

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