processor

package
v0.0.0-...-dc806d7 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

README

Text Data Processor.

Short Description.

The Processor receives input text Data (from a CSV File's Row) and tries to put it into an Object.

Full Description.

The full Description is available in the Source Code.

Installation.

Import Commands:

go get "github.com/legacy-vault/library/go/text_data_processor"
go get "github.com/legacy-vault/example/go/text_data_processor/code"

Usage.

Usage Example can be found at the following Address:

https://github.com/legacy-vault/example/tree/master/go/text_data_processor

Documentation

Index

Constants

View Source
const ColumnNameSeparatorSymbolDot = "."

Column Name Separator Symbols allowed.

View Source
const ColumnNameSeparatorSymbolHyphen = "-"
View Source
const ColumnNameSeparatorSymbolSpace = " "
View Source
const ColumnNameSeparatorSymbolUnderline = "_"
View Source
const EmptyString = ""
View Source
const ErrConfigurationIsNotFinished = "Processor is not configured"
View Source
const ErrFormatFieldTypeUnsupported = "Field '%v' has unsupported Type"

Error Messages' Formats.

View Source
const ErrFormatIndexOfItem = "Item '%v' is not found."
View Source
const ErrIndex = "Index is out of Bounds"

Error Messages.

View Source
const IndexOfIndexOnFailure = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type Cells

type Cells []string

type EmptyInterface

type EmptyInterface interface{}

type Name

type Name string

type Names

type Names []string

type Processor

type Processor struct {
	// The original List of Field Names of a reference Object.
	FieldNames Names

	// The modified Version of a previous Parameter,
	// modified for the fast Access ('FFA' means: For Fast Access).
	FieldNamesFFA Names

	// The original List of Column Names of a text (CSV) File.
	ColumnNames Names

	// The modified Version of a previous Parameter,
	// modified for the fast Access ('FFA' means: For Fast Access).
	ColumnNamesFFA Names

	// The "routing" Table. An Array of Indices.
	// The Key in this Array is of 'int' Type and represents an Index of
	// Column of the text (CSV) File. Index is Zero-based.
	// The Value (Item) in this Array is also of 'int' Type and represents an
	// Index of reference Object's Field. Index is Zero-based.
	CSVColIdxToFieldIdx RoutingTable

	// Array of Symbols used as Separators for Column Names and Field Names.
	// These Separators are removed from Names when these Names are modified
	// for fast Access.
	NameSeparatorSymbols Names

	// This Flag show whether the Processor has already been successfully
	// configured or not.
	IsConfigured bool
}

func (*Processor) Configure

func (p *Processor) Configure(
	referenceObject EmptyInterface,
	csvColumnNames Names,
) error

Configures the Processor. This Method must be run after the Processor Creation but before any Data Processing. Prepares:

  • Name Separator Symbols,
  • A modified Version of text File Column Names List,
  • A modified Version of reference Object Field Names List,
  • A "routing" Table.

func (*Processor) Process

func (p *Processor) Process(
	dataRow Cells,
	targetPointer EmptyInterface,
) error

Processes the Data. The Processor must be configured before doing any Data Processing. Reads Cells from a Row and tries to put them into the Target Object.

type RoutingTable

type RoutingTable []int

Jump to

Keyboard shortcuts

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