parser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package parser provides parsers for different banking file formats.

The several parsers implement one common interface: Parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser interface {

	// Parse the given file into internal structure.
	ParseFile(filepath string) error

	// Returns the number of parsed entries.
	GetNumberOfEntries() int

	// Convert the internal structure into HomebankRecord CSV file.
	ConvertToHomebank(filepath string) error

	// Returns the format of the parser.
	GetFormat() SourceFormat
}

Parser is the interface to be implemented by all parsers

func GetGuessedParser

func GetGuessedParser(filepath string) Parser

GetGuessedParser tries to autodetect the file format. It iterates through the available, calls the ParseFile function and returns the first parser which does not fail with an error. It returns nil if no parser could be found.

func GetParser

func GetParser(s SourceFormat) Parser

GetParser returns a parser for the given source format

type ParserError

type ParserError struct {
	ErrorType ParserErrorType

	// Optional line number where the error occurs. Line numbers are
	// 1 based. The value "0" means no line number applies here.
	Line int

	// Optional field name where the error occured
	Field string
}

ParserError describes the error which could occur during parsing

func (*ParserError) Error

func (e *ParserError) Error() string

type ParserErrorType

type ParserErrorType int

A ParserErrorType describes the type of error

const (
	IOError          ParserErrorType = iota // Error during file I/O
	HeaderError                             // Error in expected header
	DataParsingError                        // Error during parsing section
)

func (ParserErrorType) String

func (e ParserErrorType) String() string

type SourceFormat

type SourceFormat int

SourceFormat is the source file format

const (
	MoneyWallet SourceFormat = iota
	Barclaycard
	Volksbank
	Comdirect
)

Supported source format types

func GetSourceFormats

func GetSourceFormats() []SourceFormat

GetSourceFormats returns the list of supported source formats.

func NewSourceFormat

func NewSourceFormat(value SourceFormat) *SourceFormat

NewSourceFormat returns a pointer to a new SourceFormat

func (SourceFormat) String

func (s SourceFormat) String() string

Returns the textual representation of the source format Returns "unknown format" if the format is not supported

func (*SourceFormat) UnmarshalText

func (s *SourceFormat) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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