csv

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package csv mainly implements the stream/file interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInStream

func NewInStream(filename string) (file.InStream, error)

NewInStream - Creates a CSV input stream named 'filename'.

func NewOutStream

func NewOutStream(filename string) (file.OutStream, error)

NewOutStream - Creates a CSV output stream named 'filename'.

func NewRows

func NewRows(f *os.File, c *config.JSON) (file.Rows, error)

NewRows - Creates a row reader using the file handle 'f' and configuration 'c'.

func NewWriter

func NewWriter(f *os.File, c *config.JSON) (file.StreamWriter, error)

NewWriter - Creates a CSV stream writer using the file handle 'f' and configuration 'c'.

Types

type Column

type Column struct {
	Index  string `json:"index"`  // Index starts from 1 and represents the column number
	Type   string `json:"type"`   // Type (bool, bigInt, decimal, string, time)
	Format string `json:"format"` // Joda time format
	// contains filtered or unexported fields
}

Column represents column information

type Creator

type Creator struct {
}

Creator - A utility for creating CSV output streams.

func (*Creator) Create

func (c *Creator) Create(filename string) (file.OutStream, error)

Create - Creates a CSV output stream named 'filename'.

type InConfig

type InConfig struct {
	Columns    []Column `json:"column"`     // Column information
	Encoding   string   `json:"encoding"`   // Encoding
	Delimiter  string   `json:"delimiter"`  // Delimiter
	NullFormat string   `json:"nullFormat"` // Null text
	StartRow   int      `json:"startRow"`   // Starting row for reading, starting from 1
	Comment    string   `json:"comment"`    // Comments
	Compress   string   `json:"compress"`   // Compression
}

InConfig represents the CSV configuration

func NewInConfig

func NewInConfig(conf *config.JSON) (c *InConfig, err error)

NewInConfig retrieves the CSV configuration from the given conf

type Opener

type Opener struct {
}

Opener - A utility for opening CSV input streams.

func (*Opener) Open

func (o *Opener) Open(filename string) (file.InStream, error)

Open - Opens a CSV input stream named 'filename'.

type OutConfig

type OutConfig struct {
	Columns    []Column `json:"column"`     // Column information
	Encoding   string   `json:"encoding"`   // Encoding
	Delimiter  string   `json:"delimiter"`  // Delimiter
	NullFormat string   `json:"nullFormat"` // Null text
	HasHeader  bool     `json:"hasHeader"`  // Whether there is a column header
	Header     []string `json:"header"`     // Column header
	Compress   string   `json:"compress"`   // Compression
}

OutConfig represents the CSV configuration

func NewOutConfig

func NewOutConfig(conf *config.JSON) (c *OutConfig, err error)

NewOutConfig retrieves the CSV configuration from the given conf

type Rows

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

Rows - Represents a row reader for CSV data.

func (*Rows) Close

func (r *Rows) Close() error

Close - Closes the read file stream.

func (*Rows) Error

func (r *Rows) Error() error

Error - An error occurred during reading.

func (*Rows) Next

func (r *Rows) Next() bool

Next - Checks if there is a next row.

func (*Rows) Scan

func (r *Rows) Scan() (columns []element.Column, err error)

Scan - Scans the data into columns.

type Stream

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

Stream - Represents a CSV file stream.

func (*Stream) Close

func (s *Stream) Close() (err error)

Close - Closes the file stream.

func (*Stream) Rows

func (s *Stream) Rows(conf *config.JSON) (rows file.Rows, err error)

Rows - Creates a new CSV row reader with the given configuration 'conf'.

func (*Stream) Writer

func (s *Stream) Writer(conf *config.JSON) (file.StreamWriter, error)

Writer - Creates a new CSV stream writer with the given configuration 'conf'.

type Writer

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

Writer - Represents a CSV stream writer.

func (*Writer) Close

func (w *Writer) Close() (err error)

Close - Closes the writer.

func (*Writer) Flush

func (w *Writer) Flush() (err error)

Flush - Flushes the data to disk.

func (*Writer) Write

func (w *Writer) Write(record element.Record) (err error)

Write - Writes the record 'record' to the CSV file.

Jump to

Keyboard shortcuts

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