dbf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error describes an error that occured when parsing a dbf record.

func NewError

func NewError(err error, recordNum uint32) *Error

NewError returns an attached to record number.

func (Error) Error

func (e Error) Error() string

type Field

type Field interface {
	Name() string
	Value() interface{}
	Equal(string) bool
}

Field provides generic access to record fields of any type.

type Header interface {
	RecordLen() uint16
	NumRecords() uint32
	FieldExists(string) bool
}

Header provides common information for all dbf version headers.

type Option

type Option func(*config)

Option funcs can be passed to Scanner.Scan().

func CharacterDecoder

func CharacterDecoder(dec *encoding.Decoder) Option

CharacterDecoder sets the encoding of character field values. By default, ASCII is assumed.

func FilterFields

func FilterFields(names ...string) Option

FilterFields allows filtering by field name. If this option is used, only these fields will be returned in the Record. Without this option, all available fields are returned.

type Record

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

Record wraps a dBase level-specific record.

func (Record) Deleted

func (r Record) Deleted() bool

Deleted returns the state of the "deleted" marker.

func (Record) Field

func (r Record) Field(name string) (Field, bool)

Field returns a field by name.

func (Record) Fields

func (r Record) Fields() []Field

Fields returns a list of all fields in the record. The order of the fields is nondeterministic.

type Scanner

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

Scanner parses a dbf file.

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner creates a new Scanner for the supplied source.

func (*Scanner) Err

func (s *Scanner) Err() error

Err returns the first error encountered when parsing records. It should be called after calling the Record method for the last time.

func (*Scanner) Header

func (s *Scanner) Header() (Header, error)

Header invokes the Header method for the appropriate dbase version scanner. A type assertion can be used to access information specific to the version.

func (*Scanner) Record

func (s *Scanner) Record() *Record

Record returns each record found in the dbf file. nil is returned once the last record has been read, or an error occurs - the Err method should be used to check for an error at this point.

func (*Scanner) Scan

func (s *Scanner) Scan(opts ...Option) error

Scan starts reading the dbf file. Records can be accessed from the Record method. An error is returned if there's a problem parsing the header. Errors that are encountered when parsing records must be checked with the Err method.

func (*Scanner) Version

func (s *Scanner) Version() (Version, error)

Version reads and returns the dBase version. This function does not validate the version number.

type TablePrinter added in v1.0.0

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

TablePrinter implements a tabulated view of a shapefile.

func NewTablePrinter added in v1.0.0

func NewTablePrinter(s *Scanner, fields ...string) (*TablePrinter, error)

NewTablePrinter creates a TablePrinter for the supplied dbf file, optionally displaying only the specified field names.

func (TablePrinter) PrettyPrint added in v1.0.0

func (p TablePrinter) PrettyPrint(out io.Writer) error

PrettyPrint writes a pretty ASCII table to the supplied destination.

func (TablePrinter) Print added in v1.0.0

func (p TablePrinter) Print(out io.Writer) error

Print writes a tab-delimited table to the supplied destination.

type Version

type Version uint

Version is the dBase version or "level".

const (
	DBaseLevel5 Version = 3
	DBaseLevel7 Version = 4
)

dBase versions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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