dolt: github.com/liquidata-inc/dolt/go/libraries/doltcore/table/untyped/csv Index | Files

package csv

import "github.com/liquidata-inc/dolt/go/libraries/doltcore/table/untyped/csv"

Package csv provides TableReadCloser and TableWriteCloser implementations for working with csvs.

Index

Package Files

doc.go file_info.go line.go reader.go writer.go

Variables

var ReadBufSize = 256 * 1024

ReadBufSize is the size of the buffer used when reading the csv file. It is set at the package level and all readers create their own buffer's using the value of this variable at the time they create their buffers.

var WriteBufSize = 256 * 1024

WriteBufSize is the size of the buffer used when writing a csv file. It is set at the package level and all writers create their own buffer's using the value of this variable at the time they create their buffers.

type CSVFileInfo Uses

type CSVFileInfo struct {
    // Delim says which character is used as a field delimiter
    Delim string
    // HasHeaderLine says if the csv has a header line which contains the names of the columns
    HasHeaderLine bool
    // Columns can be provided if you know the columns and their order in the csv
    Columns []string
    // EscapeQuotes says whether quotes should be escaped when parsing the csv
    EscapeQuotes bool
}

CSVFileInfo describes a csv file

func NewCSVInfo Uses

func NewCSVInfo() *CSVFileInfo

NewCSVInfo creates a new CSVInfo struct with default values

func (*CSVFileInfo) SetColumns Uses

func (info *CSVFileInfo) SetColumns(columns []string) *CSVFileInfo

SetColumns sets the Columns member and returns the CSVFileInfo

func (*CSVFileInfo) SetDelim Uses

func (info *CSVFileInfo) SetDelim(delim string) *CSVFileInfo

SetDelim sets the Delim member and returns the CSVFileInfo

func (*CSVFileInfo) SetEscapeQuotes Uses

func (info *CSVFileInfo) SetEscapeQuotes(escapeQuotes bool) *CSVFileInfo

SetEscapeQuotes sets the EscapeQuotes member and returns the CSVFileInfo

func (*CSVFileInfo) SetHasHeaderLine Uses

func (info *CSVFileInfo) SetHasHeaderLine(hasHeaderLine bool) *CSVFileInfo

SetHasHeaderLine sets the HeaderLine member and returns the CSVFileInfo

type CSVReader Uses

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

CSVReader implements TableReader. It reads csv files and returns rows.

func NewCSVReader Uses

func NewCSVReader(nbf *types.NomsBinFormat, r io.ReadCloser, info *CSVFileInfo) (*CSVReader, error)

NewCSVReader creates a CSVReader from a given ReadCloser. The CSVFileInfo should describe the csv file being read.

func OpenCSVReader Uses

func OpenCSVReader(nbf *types.NomsBinFormat, path string, fs filesys.ReadableFS, info *CSVFileInfo) (*CSVReader, error)

OpenCSVReader opens a reader at a given path within a given filesys. The CSVFileInfo should describe the csv file being opened.

func (*CSVReader) Close Uses

func (csvr *CSVReader) Close(ctx context.Context) error

Close should release resources being held

func (*CSVReader) GetSchema Uses

func (csvr *CSVReader) GetSchema() schema.Schema

GetSchema gets the schema of the rows that this reader will return

func (*CSVReader) ReadRow Uses

func (csvr *CSVReader) ReadRow(ctx context.Context) (row.Row, error)

ReadRow reads a row from a table. If there is a bad row the returned error will be non nil, and callin IsBadRow(err) will be return true. This is a potentially non-fatal error and callers can decide if they want to continue on a bad row, or fail.

func (*CSVReader) VerifySchema Uses

func (csvr *CSVReader) VerifySchema(outSch schema.Schema) (bool, error)

VerifySchema checks that the in schema matches the original schema

type CSVWriter Uses

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

CSVWriter implements TableWriter. It writes rows as comma separated string values

func NewCSVWriter Uses

func NewCSVWriter(wr io.WriteCloser, outSch schema.Schema, info *CSVFileInfo) (*CSVWriter, error)

NewCSVWriter writes rows to the given WriteCloser based on the Schema and CSVFileInfo provided

func OpenCSVWriter Uses

func OpenCSVWriter(path string, fs filesys.WritableFS, outSch schema.Schema, info *CSVFileInfo) (*CSVWriter, error)

OpenCSVWriter creates a file at the given path in the given filesystem and writes out rows based on the Schema, and CSVFileInfo provided

func (*CSVWriter) Close Uses

func (csvw *CSVWriter) Close(ctx context.Context) error

Close should flush all writes, release resources being held

func (*CSVWriter) GetSchema Uses

func (csvw *CSVWriter) GetSchema() schema.Schema

GetSchema gets the schema of the rows that this writer writes

func (*CSVWriter) WriteRow Uses

func (csvw *CSVWriter) WriteRow(ctx context.Context, r row.Row) error

WriteRow will write a row to a table

Package csv imports 19 packages (graph) and is imported by 2 packages. Updated 2020-03-10. Refresh now. Tools for package owners.