query

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSV

type CSV struct {
	Header   []string
	Recorder *csv.Reader
	// contains filtered or unexported fields
}

CSV is real data parser for CSV file. It should implement parser.RawDataParser interface

func NewCsvReader

func NewCsvReader(filename string) *CSV

NewCsvReader is func to create a CSV data parser

func (*CSV) Close

func (c *CSV) Close()

Close func is closer of CSV file

func (*CSV) CurrentLine

func (c *CSV) CurrentLine() string

CurrentLine is func to get current line(include the header line) Sample. Save This and got this line.

func (*CSV) CurrentLineNum

func (c *CSV) CurrentLineNum() int

CurrentLineNum is func to get current line number(include the header line) Sample. Save This and got this line.

func (*CSV) InitIndex

func (c *CSV) InitIndex(Selectors []parser.DocumentQuery)

InitIndex func will set the Index of Column in Selector

func (*CSV) Read

func (c *CSV) Read() ([]string, error)

Read func will read one line for csv record.

func (*CSV) Select

func (c *CSV) Select(s []parser.DocumentQuery) error

Select func will select the data from one line in file.

func (*CSV) SetDelimiter

func (c *CSV) SetDelimiter(r rune)

SetDelimiter is func to set CSV.Recorder.Comma

type JSON

type JSON struct {
	Recorder *bufio.Scanner
	CurrLine string
	// contains filtered or unexported fields
}

JSON is real data parser for JSON file. It should implement parser.RawDataParser interface

func NewJsonReader

func NewJsonReader(filename string) *JSON

NewJsonReader is func to create a JSON data parser

func (*JSON) Close

func (j *JSON) Close()

Close func will close the file

func (*JSON) CurrentLine

func (j *JSON) CurrentLine() string

CurrentLine func will return the current decoding record.

func (*JSON) InitIndex

func (j *JSON) InitIndex(selectors []parser.DocumentQuery)

InitIndex Set the selectors index. Useless for json there.

func (*JSON) Read

func (j *JSON) Read() (string, error)

Read func will read one line for json record

func (*JSON) Select

func (j *JSON) Select(selector []parser.DocumentQuery) (err error)

Select func will select the data from the one line in file.

type Reader

type Reader struct {
	// Comma is the field delimiter.
	// It is set to comma (',') by NewReader.
	// Comma must be a valid rune and must not be \r, \n,
	// or the Unicode replacement character (0xFFFD).
	Comma rune

	// Comment, if not 0, is the comment character. Lines beginning with the
	// Comment character without preceding whitespace are ignored.
	// With leading whitespace the Comment character becomes part of the
	// field, even if TrimLeadingSpace is true.
	// Comment must be a valid rune and must not be \r, \n,
	// or the Unicode replacement character (0xFFFD).
	// It must also not be equal to Comma.
	Comment rune

	// FieldsPerRecord is the number of expected fields per record.
	// If FieldsPerRecord is positive, Read requires each record to
	// have the given number of fields. If FieldsPerRecord is 0, Read sets it to
	// the number of fields in the first record, so that future records must
	// have the same field count. If FieldsPerRecord is negative, no check is
	// made and records may have a variable number of fields.
	FieldsPerRecord int

	// If LazyQuotes is true, a quote may appear in an unquoted field and a
	// non-doubled quote may appear in a quoted field.
	LazyQuotes bool

	// If TrimLeadingSpace is true, leading white space in a field is ignored.
	// This is done even if the field delimiter, Comma, is white space.
	TrimLeadingSpace bool

	// ReuseRecord controls whether calls to Read may return a slice sharing
	// the backing array of the previous call's returned slice for performance.
	// By default, each call to Read returns newly allocated memory owned by the caller.
	ReuseRecord bool

	TrailingComma bool // Deprecated: No longer used.

	// rawBuffer is a line buffer only used by the readLine method.
	RawBuffer []byte
	// contains filtered or unexported fields
}

Hack for Got CSV File using reflect get Current Error Line Reader csv defined.

Jump to

Keyboard shortcuts

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