Documentation ¶
Index ¶
- type CSVReader
- func (r *CSVReader) CurrentLineIndex() int
- func (r *CSVReader) Get(columnName string) (string, error)
- func (r *CSVReader) GetByColumnIndex(columnIndex int) (string, error)
- func (r *CSVReader) Header() []string
- func (r *CSVReader) Next(err *error) bool
- func (r *CSVReader) ReadHeader()
- func (r *CSVReader) SetHeader(columns []string)
- func (r *CSVReader) UnmarshalLine(v interface{}) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVReader ¶
type CSVReader struct {
// contains filtered or unexported fields
}
CSVReader is a CSV reader that supports iterating and reading CSV lines into structs. The csv reader is read by default in the first line. If the header is not in the first line, you can use the WithReadHeader option to set the line where the header is located.
func (*CSVReader) CurrentLineIndex ¶
CurrentLineIndex returns the current CSV line index.
func (*CSVReader) GetByColumnIndex ¶
GetByColumnIndex returns the value by the given column index.
func (*CSVReader) ReadHeader ¶ added in v0.0.2
func (r *CSVReader) ReadHeader()
ReadHeader reads the current line, that was already read by Next as the CSV header. This method is called automatically when the CSVReader is created, use it only if you want to read the header again.
func (*CSVReader) UnmarshalLine ¶
type Option ¶
type Option func(*CSVReader)
func WithReadHeader ¶
WithReadHeader sets the line where the CSV header is located. If the value is negative, the header is not read. If the value is 0, the header is read from the first line. If the value is 1, the header is read from the second line, and so on.
The default value is 0.
func WithSeparationChar ¶
WithSeparationChar sets the CSV separation character.