Documentation
¶
Index ¶
- Variables
- func NewExporter(typ reflect.Type, opts ...ExportOption) tabular.Exporter
- func NewExporterFor[T any](opts ...ExportOption) tabular.Exporter
- func NewImporter(typ reflect.Type, opts ...ImportOption) tabular.Importer
- func NewImporterFor[T any](opts ...ImportOption) tabular.Importer
- type ExportOption
- type ImportOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDataMustBeSlice indicates exported data must be a slice. ErrDataMustBeSlice = errors.New("data must be a slice") // ErrNoDataRowsFound indicates there are no data rows after skips/header. ErrNoDataRowsFound = errors.New("no data rows found") // ErrDuplicateColumnName indicates duplicate header column name. ErrDuplicateColumnName = errors.New("duplicate column name") // ErrFieldNotSettable indicates struct field is not settable during import. ErrFieldNotSettable = errors.New("field is not settable") )
Functions ¶
func NewExporter ¶
func NewExporter(typ reflect.Type, opts ...ExportOption) tabular.Exporter
NewExporter creates a new Exporter with the specified type.
func NewExporterFor ¶
func NewExporterFor[T any](opts ...ExportOption) tabular.Exporter
NewExporterFor creates a new Exporter with the specified type T.
func NewImporter ¶
func NewImporter(typ reflect.Type, opts ...ImportOption) tabular.Importer
NewImporter creates a new Importer with the specified type.
func NewImporterFor ¶
func NewImporterFor[T any](opts ...ImportOption) tabular.Importer
NewImporterFor creates a new Importer with the specified type T.
Types ¶
type ExportOption ¶
type ExportOption func(*exportOptions)
ExportOption is a function that configures exportOptions.
func WithCRLF ¶
func WithCRLF() ExportOption
WithCRLF enables using \r\n as line terminator instead of \n. By default, useCRLF is false, so calling this function sets it to true.
func WithExportDelimiter ¶
func WithExportDelimiter(delimiter rune) ExportOption
WithExportDelimiter sets the field delimiter for export.
func WithoutWriteHeader ¶
func WithoutWriteHeader() ExportOption
WithoutWriteHeader disables writing the header row. By default, writeHeader is true, so calling this function sets it to false.
type ImportOption ¶
type ImportOption func(*importOptions)
ImportOption is a function that configures importOptions.
func WithComment ¶
func WithComment(comment rune) ImportOption
WithComment sets the comment character.
func WithImportDelimiter ¶
func WithImportDelimiter(delimiter rune) ImportOption
WithImportDelimiter sets the field delimiter for import.
func WithSkipRows ¶
func WithSkipRows(rows int) ImportOption
WithSkipRows sets the number of rows to skip before the header row.
func WithoutHeader ¶
func WithoutHeader() ImportOption
WithoutHeader indicates the CSV file does not have a header row. By default, hasHeader is true, so calling this function sets it to false.
func WithoutTrimSpace ¶
func WithoutTrimSpace() ImportOption
WithoutTrimSpace disables trimming of leading/trailing spaces. By default, trimSpace is true, so calling this function sets it to false.