Documentation
¶
Index ¶
- Constants
- Variables
- func Cell(col, row int) string
- func CellNameToCoordinates(cell string) (col, row int, err error)
- func Cells(startCol, startRow, endCol, endRow int) string
- func CoordinatesToCellName(col, row int) (string, error)
- func SniffDelimiter(data []byte) rune
- func SniffHeader(rows [][]string) bool
- type CellError
- type CellRange
- type CellType
- type Encoding
- type ErrorMode
- type File
- func (f *File) AppendCol(header string, values []any) error
- func (f *File) AppendRecord(record map[string]any) error
- func (f *File) AppendRow(values []any) error
- func (f *File) AppendRows(rows [][]any) error
- func (f *File) AppendStrRow(values []string) error
- func (f *File) ClearRows() error
- func (f *File) Close() error
- func (f *File) ColCount() int
- func (f *File) Dimension() string
- func (f *File) GetByHeader(row int, header string) (string, error)
- func (f *File) GetCellBool(cellRef string) (bool, error)
- func (f *File) GetCellDate(cellRef string) (time.Time, error)
- func (f *File) GetCellFloat(cellRef string) (float64, error)
- func (f *File) GetCellInt(cellRef string) (int64, error)
- func (f *File) GetCellStr(cellRef string) (string, error)
- func (f *File) GetCellType(cellRef string) (CellType, error)
- func (f *File) GetCellValue(cellRef string) (string, error)
- func (f *File) GetCol(col int) ([]string, error)
- func (f *File) GetColByName(header string) ([]string, error)
- func (f *File) GetRecord(row int) (map[string]string, error)
- func (f *File) GetRecords() ([]map[string]string, error)
- func (f *File) GetRow(row int) ([]string, error)
- func (f *File) GetRows() ([][]string, error)
- func (f *File) HasHeader() bool
- func (f *File) HeaderIndex(name string) (int, bool)
- func (f *File) Headers() []string
- func (f *File) InsertCol(at int, header string, values []any) error
- func (f *File) InsertRow(at int, values []any) error
- func (f *File) NewRowIterator() (*RowIterator, error)
- func (f *File) ParseErrors() []*ParseError
- func (f *File) Path() string
- func (f *File) Range(rangeRef string) *CellRange
- func (f *File) RemoveCol(col int) error
- func (f *File) RemoveColByName(header string) error
- func (f *File) RemoveRow(row int) error
- func (f *File) RowCount() int
- func (f *File) Save() error
- func (f *File) SaveAs(path string) error
- func (f *File) SetByHeader(row int, header string, value any) error
- func (f *File) SetCellBool(cellRef string, value bool) error
- func (f *File) SetCellDate(cellRef string, value time.Time) error
- func (f *File) SetCellFloat(cellRef string, value float64) error
- func (f *File) SetCellInt(cellRef string, value int64) error
- func (f *File) SetCellStr(cellRef, value string) error
- func (f *File) SetCellValue(cellRef string, value any) error
- func (f *File) SetColValues(col int, values []any) error
- func (f *File) SetHeaders(headers []string) error
- func (f *File) SetRowValues(row int, values []any) error
- func (f *File) Write(w io.Writer) error
- func (f *File) WriteToBuffer() (*bytes.Buffer, error)
- func (f *File) WriteToFile(path string) error
- type Option
- func WithBufferSize(n int) Option
- func WithCRLF(enabled bool) Option
- func WithComment(r rune) Option
- func WithDelimiter(r rune) Option
- func WithEncoding(e Encoding) Option
- func WithErrorMode(m ErrorMode) Option
- func WithFieldsPerRecord(n int) Option
- func WithHeader(enabled bool) Option
- func WithLazyQuotes(enabled bool) Option
- func WithParallel(n int) Option
- func WithParallelThreshold(size int) Option
- func WithQuote(r rune) Option
- func WithSkipRows(n int) Option
- func WithStdlibParser() Option
- func WithTrimLeadingSpace(enabled bool) Option
- func WithUnsafeStrings() Option
- func WithWriteBOM(enabled bool) Option
- type ParseError
- type RowIterator
- type StreamWriter
- func (sw *StreamWriter) Close() error
- func (sw *StreamWriter) Flush() error
- func (sw *StreamWriter) WriteHeader(headers []string) error
- func (sw *StreamWriter) WriteRecord(record map[string]any) error
- func (sw *StreamWriter) WriteRow(values []any) error
- func (sw *StreamWriter) WriteStrRow(values []string) error
Constants ¶
View Source
const ( EncodingAuto = encoding.EncodingAuto EncodingUTF8 = encoding.EncodingUTF8 EncodingUTF16LE = encoding.EncodingUTF16LE EncodingUTF16BE = encoding.EncodingUTF16BE EncodingISO88591 = encoding.EncodingISO88591 EncodingWindows1252 = encoding.EncodingWindows1252 )
View Source
const ( ErrorModeStrict = dialect.ErrorModeStrict ErrorModeSkip = dialect.ErrorModeSkip ErrorModeCollect = dialect.ErrorModeCollect )
Variables ¶
View Source
var ( ErrFileClosed = errors.New("gocsv: file is closed") ErrInvalidCell = errors.New("gocsv: invalid cell reference") ErrInvalidCoords = errors.New("gocsv: invalid coordinates") ErrInvalidRange = errors.New("gocsv: invalid range") ErrRowOutOfRange = errors.New("gocsv: row out of range") ErrColumnOutOfRange = errors.New("gocsv: column out of range") ErrHeaderNotFound = errors.New("gocsv: header not found") ErrNoHeader = errors.New("gocsv: file has no header row") ErrFieldCount = errors.New("gocsv: row field count mismatch") ErrUnsupportedType = errors.New("gocsv: unsupported value type") ErrBareQuote = errors.New("gocsv: bare quote in unquoted field") ErrUnclosedQuote = errors.New("gocsv: unclosed quoted field") ErrEncodingInvalid = errors.New("gocsv: invalid encoding") ErrInvalidDelimiter = errors.New("gocsv: invalid delimiter") ErrStreamClosed = errors.New("gocsv: stream is closed") )
Functions ¶
func CellNameToCoordinates ¶
func CoordinatesToCellName ¶
func SniffDelimiter ¶
func SniffHeader ¶
Types ¶
type CellRange ¶
type CellRange struct {
// contains filtered or unexported fields
}
func (*CellRange) Dimensions ¶
type Encoding ¶
func SniffEncoding ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) AppendRows ¶
func (*File) AppendStrRow ¶
func (*File) NewRowIterator ¶
func (f *File) NewRowIterator() (*RowIterator, error)
func (*File) ParseErrors ¶
func (f *File) ParseErrors() []*ParseError
func (*File) RemoveColByName ¶
func (*File) SetCellStr ¶
func (*File) SetHeaders ¶
func (*File) WriteToFile ¶
type Option ¶
type Option func(*config)
func WithBufferSize ¶
func WithComment ¶
func WithDelimiter ¶
func WithEncoding ¶
func WithErrorMode ¶
func WithFieldsPerRecord ¶
func WithHeader ¶
func WithLazyQuotes ¶
func WithParallel ¶ added in v0.2.0
func WithParallelThreshold ¶ added in v0.2.0
func WithSkipRows ¶
func WithStdlibParser ¶
func WithStdlibParser() Option
func WithTrimLeadingSpace ¶
func WithUnsafeStrings ¶ added in v0.2.0
func WithUnsafeStrings() Option
func WithWriteBOM ¶
type ParseError ¶
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type RowIterator ¶
type RowIterator struct {
// contains filtered or unexported fields
}
func NewRowIteratorFromFunc ¶ added in v0.3.0
func StreamReader ¶
func StreamReader(r io.Reader, opts ...Option) (*RowIterator, error)
func StreamReaderFromFile ¶
func StreamReaderFromFile(path string, opts ...Option) (*RowIterator, error)
func (*RowIterator) Close ¶
func (it *RowIterator) Close() error
func (*RowIterator) Error ¶
func (it *RowIterator) Error() error
func (*RowIterator) Headers ¶
func (it *RowIterator) Headers() []string
func (*RowIterator) Next ¶
func (it *RowIterator) Next() bool
func (*RowIterator) Record ¶
func (it *RowIterator) Record() map[string]string
func (*RowIterator) Row ¶
func (it *RowIterator) Row() []string
func (*RowIterator) RowIndex ¶
func (it *RowIterator) RowIndex() int
type StreamWriter ¶
type StreamWriter struct {
// contains filtered or unexported fields
}
func NewStreamWriter ¶
func NewStreamWriter(w io.Writer, opts ...Option) *StreamWriter
func NewStreamWriterToFile ¶
func NewStreamWriterToFile(path string, opts ...Option) (*StreamWriter, error)
func (*StreamWriter) Close ¶
func (sw *StreamWriter) Close() error
func (*StreamWriter) Flush ¶
func (sw *StreamWriter) Flush() error
func (*StreamWriter) WriteHeader ¶
func (sw *StreamWriter) WriteHeader(headers []string) error
func (*StreamWriter) WriteRecord ¶
func (sw *StreamWriter) WriteRecord(record map[string]any) error
func (*StreamWriter) WriteRow ¶
func (sw *StreamWriter) WriteRow(values []any) error
func (*StreamWriter) WriteStrRow ¶
func (sw *StreamWriter) WriteStrRow(values []string) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.