dbcsv

package module
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown = FileType("")
	Csv     = FileType("csv")
	Xls     = FileType("xls")
	XlsX    = FileType("xlsx")
)
View Source
const (
	DateFormat     = "20060102"
	DateTimeFormat = "20060102150405"
)

Variables

View Source
var DefaultEncoding = NamedEncoding{Encoding: encoding.Replacement, Name: "utf-8"}
View Source
var UnknownSheet = errors.New("unknown sheet")

Functions

func ReadCSV

func ReadCSV(ctx context.Context, fn func(Row) error, r io.Reader, delim string, columns []int, skip int) error

func ReadXLSFile

func ReadXLSFile(ctx context.Context, fn func(string, Row) error, filename string, charset string, sheetIndex int, columns []int, skip int) error

func ReadXLSXFile

func ReadXLSXFile(ctx context.Context, fn func(string, Row) error, filename string, sheetIndex int, columns []int, skip int) error

func Wrap added in v0.0.5

Wrap returns a new context with cancel that is canceled on interrupts.

Types

type Config

type Config struct {
	Sheet, Skip   int
	Delim         string
	Charset       string
	ColumnsString string
	// contains filtered or unexported fields
}

func (*Config) Close

func (cfg *Config) Close() error

func (*Config) Columns

func (cfg *Config) Columns() ([]int, error)

func (*Config) Encoding

func (cfg *Config) Encoding() (encoding.Encoding, error)

func (*Config) Open

func (cfg *Config) Open(fileName string) error

func (*Config) OpenVolatile

func (cfg *Config) OpenVolatile(fileName string) error

func (*Config) ReadRows

func (cfg *Config) ReadRows(ctx context.Context, fn func(string, Row) error) (err error)

func (*Config) ReadSheets added in v0.0.5

func (cfg *Config) ReadSheets(ctx context.Context) (map[int]string, error)

func (*Config) Type

func (cfg *Config) Type() (FileType, error)

type FileType

type FileType string

func DetectReaderType

func DetectReaderType(r io.Reader, fileName string) (FileType, error)

type NamedEncoding added in v0.0.4

type NamedEncoding struct {
	encoding.Encoding
	Name string
}

func EncFromName added in v0.0.4

func EncFromName(e string) (NamedEncoding, error)

type Row

type Row struct {
	Line   int
	Values []string
}

type StringsValue added in v0.0.4

type StringsValue struct {
	Strings []string
}

func FlagStrings added in v0.0.4

func FlagStrings() *StringsValue

func (*StringsValue) Set added in v0.0.4

func (ss *StringsValue) Set(s string) error

func (StringsValue) String added in v0.0.4

func (ss StringsValue) String() string

Directories

Path Synopsis
Package main in csvdump represents a cursor->csv dumper
Package main in csvdump represents a cursor->csv dumper
Package main in paraexp represents a parallel query-to-JSON dumper
Package main in paraexp represents a parallel query-to-JSON dumper
Package main in tablecopy is a table copier between databases.
Package main in tablecopy is a table copier between databases.

Jump to

Keyboard shortcuts

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