Documentation ¶
Index ¶
- Variables
- func CompactSpacedStrings(rows [][]string) (numModified int)
- func ParseFileWithFormat(ctx context.Context, csvFile fs.FileReader, format *Format) (rows [][]string, err error)
- func ParseWithFormat(data []byte, format *Format) (rows [][]string, err error)
- func RemoveEmptyRows(rows [][]string) [][]string
- func ReplaceNewlineWithSpacefunc(rows [][]string)
- func SetEmptyRowsNil(rows [][]string) [][]string
- func SetRowsWithNonUniformColumnsNil(rows [][]string) [][]string
- type ColumnMapping
- type CompactSpacedStringsModifier
- type DataType
- type Format
- func NewFormat(separator string) *Format
- func ParseDetectFormat(data []byte, configOrNil *FormatDetectionConfig) (rows [][]string, format *Format, err error)
- func ParseFileDetectFormat(ctx context.Context, csvFile fs.FileReader, configOrNil *FormatDetectionConfig) (rows [][]string, format *Format, err error)
- type FormatDetectionConfig
- type Modifier
- type ModifierList
- type Reader
- func NewReader(reader io.Reader, format *Format, newlineReplacement string, ...) (r *Reader, err error)
- func NewReaderFromFile(file fs.FileReader, format *Format, newlineReplacement string, ...) (r *Reader, err error)
- func NewReaderFromRows(rows [][]string, format *Format, newlineReplacement string, ...) (r *Reader, err error)
- type RemoveBottomRowModifier
- type RemoveEmptyRowsModifier
- type RemoveTopRowModifier
- type Renderer
- func (*Renderer) MIMEType() string
- func (csv *Renderer) RenderBeginTableText(writer io.Writer) error
- func (*Renderer) RenderEndTableText(writer io.Writer) error
- func (csv *Renderer) RenderHeaderRowText(writer io.Writer, columnTitles []string) error
- func (csv *Renderer) RenderRowText(writer io.Writer, fields []string) error
- func (csv *Renderer) SetDelimiter(delimiter string) error
- func (csv *Renderer) WithDelimiter(delimiter string) *Renderer
- func (csv *Renderer) WithFormat(format *Format) *Renderer
- func (csv *Renderer) WithHeaderComment(headerSuffix string) *Renderer
- func (csv *Renderer) WithQuoteAllFields(quote bool) *Renderer
- func (csv *Renderer) WithQuoteEmptyFields(quote bool) *Renderer
- type ReplaceNewlineWithSpaceModifier
- type SetBottomRowNilModifier
- type SetEmptyRowsNilModifier
- type SetRowsWithNonUniformColumnsNilModifier
- type SetTopRowNilModifier
Constants ¶
This section is empty.
Variables ¶
var ModifiersByName = map[string]Modifier{ SetRowsWithNonUniformColumnsNilModifier{}.Name(): SetRowsWithNonUniformColumnsNilModifier{}, SetEmptyRowsNilModifier{}.Name(): SetEmptyRowsNilModifier{}, RemoveEmptyRowsModifier{}.Name(): RemoveEmptyRowsModifier{}, CompactSpacedStringsModifier{}.Name(): CompactSpacedStringsModifier{}, RemoveTopRowModifier{}.Name(): RemoveTopRowModifier{}, RemoveBottomRowModifier{}.Name(): RemoveBottomRowModifier{}, SetTopRowNilModifier{}.Name(): SetTopRowNilModifier{}, SetBottomRowNilModifier{}.Name(): SetBottomRowNilModifier{}, ReplaceNewlineWithSpaceModifier{}.Name(): ReplaceNewlineWithSpaceModifier{}, }
Functions ¶
func CompactSpacedStrings ¶
CompactSpacedStrings removes spaces if they are between every other character, meaning that every odd character index is a space.
func ParseFileWithFormat ¶
func ParseWithFormat ¶
func RemoveEmptyRows ¶
RemoveEmptyRows removes rows without columns, or rows where all columns are empty strings.
func ReplaceNewlineWithSpacefunc ¶
func ReplaceNewlineWithSpacefunc(rows [][]string)
func SetEmptyRowsNil ¶
SetEmptyRowsNil sets rows to nil, where all columns are empty strings.
func SetRowsWithNonUniformColumnsNil ¶
SetRowsWithNonUniformColumnsNil set rows to nil that don't have the same field count as the majority of rows, so every rows is either nil or has the same number of fields.
Types ¶
type ColumnMapping ¶
type CompactSpacedStringsModifier ¶
type CompactSpacedStringsModifier struct{}
func (CompactSpacedStringsModifier) Modify ¶
func (m CompactSpacedStringsModifier) Modify(rows [][]string) [][]string
func (CompactSpacedStringsModifier) Name ¶
func (m CompactSpacedStringsModifier) Name() string
type DataType ¶
type DataType string
const ( DataTypeString DataType = "STRING" DataTypeNullableString DataType = "NULL_STRING" DataTypeInt DataType = "INT" DataTypeNullableInt DataType = "NULL_INT" DataTypeFloat DataType = "FLOAT" DataTypeNullableFloat DataType = "NULL_FLOAT" DataTypeMoneyAmount DataType = "MONEY_AMOUNT" DataTypeNullableMoneyAmount DataType = "NULL_MONEY_AMOUNT" DataTypeCurrency DataType = "CURRENCY" DataTypeNullableCurrency DataType = "NULL_CURRENCY" DataTypeDate DataType = "DATE" DataTypeNullableDate DataType = "NULL_DATE" DataTypeTime DataType = "TIME" DataTypeNullableTime DataType = "NULL_TIME" DataTypeIBAN DataType = "IBAN" DataTypeNullableIBAN DataType = "NULL_IBAN" DataTypeBIC DataType = "BIC" DataTypeNullableBIC DataType = "NULL_BIC" )
func StringDataTypes ¶
StringDataTypes returns valid non nullable data types for the passed string. DataTypeString is not returned because it's always valid.
type Format ¶
type Format struct { Encoding string `json:"encoding"` Separator string `json:"separator"` Newline string `json:"newline"` }
func NewFormat ¶
NewFormat returns a Format with the passed separator, UTF-8 encoding, and "\r\n" newlines.
func ParseDetectFormat ¶
func ParseDetectFormat(data []byte, configOrNil *FormatDetectionConfig) (rows [][]string, format *Format, err error)
ParseDetectFormat returns a slice of strings per row with the format detected via the FormatDetectionConfig.
func ParseFileDetectFormat ¶
func ParseFileDetectFormat(ctx context.Context, csvFile fs.FileReader, configOrNil *FormatDetectionConfig) (rows [][]string, format *Format, err error)
ParseFileDetectFormat returns a slice of strings per row with the format detected via the FormatDetectionConfig.
type FormatDetectionConfig ¶
type FormatDetectionConfig struct { Encodings []string `json:"encodings"` EncodingTests []string `json:"encodingTests"` }
func NewFormatDetectionConfig ¶
func NewFormatDetectionConfig() *FormatDetectionConfig
type ModifierList ¶
type ModifierList []Modifier
func (ModifierList) MarshalJSON ¶
func (l ModifierList) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler
func (ModifierList) Modify ¶
func (l ModifierList) Modify(rows [][]string) [][]string
func (*ModifierList) UnmarshalJSON ¶
func (l *ModifierList) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler
type Reader ¶
type Reader struct { Format *Format `json:"format,omitempty"` FormatDetection *FormatDetectionConfig `json:"formatDetection,omitempty"` ScanConfig *strfmt.ScanConfig `json:"config"` Modifiers ModifierList `json:"modifiers"` Columns []ColumnMapping `json:"columns"` // contains filtered or unexported fields }
func NewReader ¶
func NewReader(reader io.Reader, format *Format, newlineReplacement string, modifiers ModifierList, columns []ColumnMapping, scanConfig ...*strfmt.ScanConfig) (r *Reader, err error)
NewReader reads from an io.Reader
func NewReaderFromFile ¶
func NewReaderFromFile(file fs.FileReader, format *Format, newlineReplacement string, modifiers ModifierList, columns []ColumnMapping, scanConfig ...*strfmt.ScanConfig) (r *Reader, err error)
NewReaderFromFile reads from a fs.FileReader
func NewReaderFromRows ¶
func NewReaderFromRows(rows [][]string, format *Format, newlineReplacement string, modifiers ModifierList, columns []ColumnMapping, scanConfig ...*strfmt.ScanConfig) (r *Reader, err error)
NewReaderFromRows returns a Reader that uses pre-parsed rows
type RemoveBottomRowModifier ¶
type RemoveBottomRowModifier struct{}
RemoveBottomRowModifier removes the given number of rows at the bottom
func (RemoveBottomRowModifier) Modify ¶
func (m RemoveBottomRowModifier) Modify(rows [][]string) [][]string
func (RemoveBottomRowModifier) Name ¶
func (m RemoveBottomRowModifier) Name() string
type RemoveEmptyRowsModifier ¶
type RemoveEmptyRowsModifier struct{}
func (RemoveEmptyRowsModifier) Modify ¶
func (m RemoveEmptyRowsModifier) Modify(rows [][]string) [][]string
func (RemoveEmptyRowsModifier) Name ¶
func (m RemoveEmptyRowsModifier) Name() string
type RemoveTopRowModifier ¶
type RemoveTopRowModifier struct{}
RemoveTopRowModifier removes the given number of rows at the top
func (RemoveTopRowModifier) Modify ¶
func (m RemoveTopRowModifier) Modify(rows [][]string) [][]string
func (RemoveTopRowModifier) Name ¶
func (m RemoveTopRowModifier) Name() string
type Renderer ¶
type Renderer struct { *structtable.TextRenderer // contains filtered or unexported fields }
func NewRenderer ¶
func NewRenderer(config *strfmt.FormatConfig) *Renderer
func (*Renderer) RenderBeginTableText ¶
func (*Renderer) RenderHeaderRowText ¶
func (*Renderer) RenderRowText ¶
func (*Renderer) SetDelimiter ¶
func (*Renderer) WithDelimiter ¶
func (*Renderer) WithFormat ¶
func (*Renderer) WithHeaderComment ¶
func (*Renderer) WithQuoteAllFields ¶
func (*Renderer) WithQuoteEmptyFields ¶
type ReplaceNewlineWithSpaceModifier ¶
type ReplaceNewlineWithSpaceModifier struct{}
func (ReplaceNewlineWithSpaceModifier) Modify ¶
func (m ReplaceNewlineWithSpaceModifier) Modify(rows [][]string) [][]string
func (ReplaceNewlineWithSpaceModifier) Name ¶
func (m ReplaceNewlineWithSpaceModifier) Name() string
type SetBottomRowNilModifier ¶
type SetBottomRowNilModifier struct{}
SetBottomRowNilModifier removes the given number of rows at the bottom
func (SetBottomRowNilModifier) Modify ¶
func (m SetBottomRowNilModifier) Modify(rows [][]string) [][]string
func (SetBottomRowNilModifier) Name ¶
func (m SetBottomRowNilModifier) Name() string
type SetEmptyRowsNilModifier ¶
type SetEmptyRowsNilModifier struct{}
func (SetEmptyRowsNilModifier) Modify ¶
func (m SetEmptyRowsNilModifier) Modify(rows [][]string) [][]string
func (SetEmptyRowsNilModifier) Name ¶
func (m SetEmptyRowsNilModifier) Name() string
type SetRowsWithNonUniformColumnsNilModifier ¶
type SetRowsWithNonUniformColumnsNilModifier struct{}
func (SetRowsWithNonUniformColumnsNilModifier) Modify ¶
func (m SetRowsWithNonUniformColumnsNilModifier) Modify(rows [][]string) [][]string
func (SetRowsWithNonUniformColumnsNilModifier) Name ¶
func (m SetRowsWithNonUniformColumnsNilModifier) Name() string
type SetTopRowNilModifier ¶
type SetTopRowNilModifier struct{}
SetTopRowNilModifier removes the given number of rows at the top
func (SetTopRowNilModifier) Modify ¶
func (m SetTopRowNilModifier) Modify(rows [][]string) [][]string
func (SetTopRowNilModifier) Name ¶
func (m SetTopRowNilModifier) Name() string