csv

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nil = rune(0)
	CR  = '\r'
	LF  = '\n'
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvQuoteState

type CsvQuoteState struct{}

Implements a quote string state object for CSV streams.

func NewCsvQuoteState

func NewCsvQuoteState() *CsvQuoteState

func (*CsvQuoteState) DecodeString

func (c *CsvQuoteState) DecodeString(value string, quoteSymbol rune) string

Decodes a string value.

Parameters:

  • value: A string value to be decoded.
  • quoteSymbol: A string quote character.

Returns: An decoded string.

func (*CsvQuoteState) EncodeString

func (c *CsvQuoteState) EncodeString(value string, quoteSymbol rune) string

Encodes a string value.

Parameters:

  • value: A string value to be encoded.
  • quoteSymbol: A string quote character.

Returns: An encoded string.

func (*CsvQuoteState) NextToken

func (c *CsvQuoteState) NextToken(
	scanner io.IScanner, tokenizer tokenizers.ITokenizer) *tokenizers.Token

Gets the next token from the stream started from the character linked to this state.

Parameters:

  • scanner: A textual string to be tokenized.
  • tokenizer: A tokenizer class that controls the process.

Returns: The next token from the top of the stream.

type CsvSymbolState

type CsvSymbolState struct {
	generic.GenericSymbolState
}

Implements a symbol state to tokenize delimiters in CSV streams.

func NewCsvSymbolState

func NewCsvSymbolState() *CsvSymbolState

Constructs this object with specified parameters.

func (*CsvSymbolState) NextToken

func (c *CsvSymbolState) NextToken(
	scanner io.IScanner, tokenizer tokenizers.ITokenizer) *tokenizers.Token

type CsvTokenizer

type CsvTokenizer struct {
	tokenizers.AbstractTokenizer
	// contains filtered or unexported fields
}

Implements a tokenizer class for CSV files.

func NewCsvTokenizer

func NewCsvTokenizer() *CsvTokenizer

Constructs this object with default parameters.

func (*CsvTokenizer) AssignStates

func (c *CsvTokenizer) AssignStates()

Assigns tokenizer states to correct characters.

func (*CsvTokenizer) EndOfLine

func (c *CsvTokenizer) EndOfLine() string

Gets a separator for rows in CSV stream.

func (*CsvTokenizer) FieldSeparators

func (c *CsvTokenizer) FieldSeparators() []rune

Gets separators for fields in CSV stream.

func (*CsvTokenizer) QuoteSymbols

func (c *CsvTokenizer) QuoteSymbols() []rune

Gets characters to quote strings

func (*CsvTokenizer) SetEndOfLine

func (c *CsvTokenizer) SetEndOfLine(value string)

Sets a separator for rows in CSV stream.

func (*CsvTokenizer) SetFieldSeparators

func (c *CsvTokenizer) SetFieldSeparators(value []rune)

Sets separators for fields in CSV stream.

func (*CsvTokenizer) SetQuoteSymbols

func (c *CsvTokenizer) SetQuoteSymbols(value []rune)

Sets characters to quote strings

type CsvWordState

type CsvWordState struct {
	generic.GenericWordState
}

Implements a word state to tokenize CSV stream.

func NewCsvWordState

func NewCsvWordState(fieldSeparators []rune, quoteSymbols []rune) *CsvWordState

Constructs this object with specified parameters.

Parameters:

  • fieldSeparators: Separators for fields in CSV stream.
  • quoteSymbol: Delimiters character to quote strings.

Jump to

Keyboard shortcuts

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