dbcsv

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown = FType("")
	Csv     = FType("csv")
	Xls     = FType("xls")
	XlsX    = FType("xlsx")
	Gzip    = FType("gzip")
	Zstd    = FType("zstd")
)
View Source
const (
	DateFormat     = "20060102"
	DateTimeFormat = "20060102150405"
)

Variables

View Source
var DefaultEncoding = NamedEncoding{Encoding: encoding.Replacement, Name: "utf-8"}
View Source
var ErrUnknownSheet = 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) 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) Rewind added in v0.0.17

func (cfg *Config) Rewind() error

func (*Config) Type

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

type FType added in v0.1.0

type FType string

type FileType

type FileType struct {
	Type        FType
	Compression FType
}

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
	Columns []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