gtfswriter

package module
v0.0.0-...-b6c6255 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: GPL-2.0 Imports: 15 Imported by: 9

README

Go Report Card Build Status GoDoc

go gtfswriter

A writer for the GTFS structure created by the go gtfsparser. This can be used to write feeds that have been changed programmatically back to a GTFS feed.

Usage

feed := gtfsparser.NewFeed()
error := feed.Parse("sample-feed.zip")

// do stuff with feed

w := gtfswriter.Writer{}
werror := w.Write(feed, "/path/to/output")

Features

Optional fields are not outputted if empty, if default values are used, the writer outputs them empty.

The ZIP compression level can be specified by setting ZipCompressionLevel:

w := gtfswriter.Writer{ZipCompressionLevel : 9}
werror := w.Write(feed, "/path/to/output")

The following options are supported:

  • 0 (default): default compression
  • 1-9: Compression levels from 1 (fastest) to 9 (best)
  • -1: no compression

Known restrictions

For direct output in ZIP file, you must create it before:

// do stuff with feed
os.Create("/path/to/output.zip")

w := gtfswriter.Writer{}
werror := w.Write(feed, "/path/to/output")

License

GPL v2, see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvWriter

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

A CsvWriter is a wrapper around csv.Writer

func NewCsvWriter

func NewCsvWriter(file io.Writer) CsvWriter

NewCsvWriter returns a new CsvWriter instance

func (*CsvWriter) Flush

func (p *CsvWriter) Flush()

Flush the current line cache into the CSV file

func (*CsvWriter) FlushFile

func (p *CsvWriter) FlushFile()

Flush the current line cache into the CSV file

func (*CsvWriter) HeaderUsage

func (p *CsvWriter) HeaderUsage(val []string)

HeaderUsage updates the header usage for a single row

func (*CsvWriter) SetHeader

func (p *CsvWriter) SetHeader(val []string, required []string)

SetHeader sets the header for this CSV file

func (*CsvWriter) SetOrder

func (p *CsvWriter) SetOrder(order []string)

func (*CsvWriter) SortByCols

func (p *CsvWriter) SortByCols(depth int)

SortByCols sorts the current line cache by depth

func (*CsvWriter) WriteCsvLine

func (p *CsvWriter) WriteCsvLine(val []string)

WriteCsvLine writes a single slice of values to the CSV file

func (*CsvWriter) WriteCsvLineRaw

func (p *CsvWriter) WriteCsvLineRaw(val []string)

WriteCsvLineRaw writes a single slice of values to the CSV file

func (*CsvWriter) WriteHeader

func (p *CsvWriter) WriteHeader()

type EntAttr

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

type Lines

type Lines [][]string

Lines describes a slice of slice-encoded CSV lines

type SortedLines

type SortedLines struct {
	Lines     Lines
	SortDepth int
}

SortedLines is a Lines object extended by information on the sorting depth (1 = sort by first column, 2 = sort by first and second column, and so on)

func (SortedLines) Len

func (l SortedLines) Len() int

func (SortedLines) Less

func (l SortedLines) Less(i, j int) bool

func (SortedLines) Swap

func (l SortedLines) Swap(i, j int)

type Writer

type Writer struct {
	ZipCompressionLevel int
	Sorted              bool
	ExplicitCalendar    bool
	KeepColOrder        bool
	DontGarbageCollect  bool
	// contains filtered or unexported fields
}

A Writer for GTFS files

func (*Writer) Write

func (writer *Writer) Write(feed *gtfsparser.Feed, path string) error

Write a single GTFS feed to a system path, either a folder or a ZIP file

Jump to

Keyboard shortcuts

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