tblconv

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 9 Imported by: 3

README

tblconv

A simple tool for converting one "table" format into another.

Supported Formats

  • CSV
    • source
    • output
  • Excel
    • source
    • output
  • SQL
    • source
    • output

CLI Features

The tblconv CLI supports all of the above formats. Some peculiarities for each format are the following.

Built-in SQL Drivers
  • Postgres
  • MySQL
  • Snowflake
  • Excel
  • CSV

Documentation

Overview

Package tblconv

Index

Constants

This section is empty.

Variables

View Source
var DefaultSheetName = "Sheet1"

DefaultSheetName

Functions

func Copy

func Copy(w Writer, r Reader) error

Copy provides the ability to copy tabulized data from one format to another.

func NewCSVReader

func NewCSVReader(r io.Reader) *csv.Reader

NewCSVReader

Types

type CSVWriter

type CSVWriter struct {
	CSV *csv.Writer
}

CSVWriter

func NewCSVWriter

func NewCSVWriter(w io.Writer) *CSVWriter

NewCSVWriter

func (*CSVWriter) Flush

func (w *CSVWriter) Flush() error

Flush

func (*CSVWriter) Write

func (w *CSVWriter) Write(record []string) error

Write

type ExcelOption

type ExcelOption func(*excelConfig)

ExcelOption

func SheetName

func SheetName(sheet string) ExcelOption

SheetName

type ExcelReader

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

ExcelReader

func NewExcelReader

func NewExcelReader(r io.Reader, opts ...ExcelOption) *ExcelReader

NewExcelReader

func (*ExcelReader) Read

func (r *ExcelReader) Read() ([]string, error)

Read

type ExcelWriter

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

ExcelWriter

func NewExcelWriter

func NewExcelWriter(w io.Writer, opts ...ExcelOption) *ExcelWriter

NewExcelWriter

func (*ExcelWriter) Flush

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

Flush

func (*ExcelWriter) Write

func (w *ExcelWriter) Write(record []string) error

Write

type Flusher added in v0.2.0

type Flusher interface {
	Flush() error
}

Flusher is an optional interface for Writers to implement if they need to be flushed after writing all the records.

type Reader

type Reader interface {
	Read() ([]string, error)
}

Reader

type RecordsReader added in v0.2.0

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

RecordsReader is implemented solely for providing a simple reader to be used in tests.

func NewRecordsReader added in v0.2.0

func NewRecordsReader(records ...[]string) *RecordsReader

NewRecordsReader

func (*RecordsReader) Read added in v0.2.0

func (r *RecordsReader) Read() ([]string, error)

Read

type RecordsWriter added in v0.2.0

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

RecordsWriter is implemented solely for providing a simple writer to be used in tests.

func NewRecordsWriter added in v0.2.0

func NewRecordsWriter() *RecordsWriter

NewRecordsWriter

func (*RecordsWriter) Flush added in v0.2.0

func (w *RecordsWriter) Flush() error

Flush

func (*RecordsWriter) Records added in v0.2.0

func (w *RecordsWriter) Records() [][]string

Records returns all of the records currently written to the RecordsWriter.

func (*RecordsWriter) Write added in v0.2.0

func (w *RecordsWriter) Write(record []string) error

Write

type SQLReader added in v0.2.0

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

SQLReader

func NewSQLReader added in v0.2.0

func NewSQLReader(db *sql.DB, query string, args ...interface{}) *SQLReader

NewSQLReader

func (*SQLReader) Read added in v0.2.0

func (r *SQLReader) Read() (record []string, err error)

Read

type SQLWriter added in v0.2.0

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

SQLWriter

func NewSQLWriter added in v0.2.0

func NewSQLWriter(db *sql.DB, query string) *SQLWriter

NewSQLWriter

func (*SQLWriter) Flush added in v0.2.0

func (w *SQLWriter) Flush() error

Flush commits the underlying sql.Tx. See SQLWriter.Write() for more details about the relationship between Write and Flush for SQLWriter.

func (*SQLWriter) Write added in v0.2.0

func (w *SQLWriter) Write(record []string) (err error)

Write uses the given record to fill an placeholder parameters in the query given when the SQLWriter was created.

Writes occur within a sql.Tx and *DO NOT* periodically auto flush. Periodic flushing is the responsibility of the caller by utilizing SQLWriter.Flush(). After flushing, a new sql.Tx will be created so with periodic flushing there is no gaurantee that all writes will occur in the same transaction.

type Writer

type Writer interface {
	Write(record []string) error
}

Writer

Directories

Path Synopsis
cmd
sql

Jump to

Keyboard shortcuts

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