Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CsvIterator ¶
type CsvIterator struct {
// contains filtered or unexported fields
}
CsvIterator helps to iterate over records in a CSV file.
func NewCsvIterator ¶
func NewCsvIterator(filePath string, skipHeader bool) (*CsvIterator, error)
NewCsvIterator creates a new CsvIterator for the given file path. If skipHeader is true, it will attempt to read and discard the first line of the CSV. The caller is responsible for calling Close() on the iterator when done.
func (*CsvIterator) Close ¶
func (it *CsvIterator) Close() error
Close closes the underlying file. It should be called when done with the iterator to release system resources.
func (*CsvIterator) Err ¶
func (it *CsvIterator) Err() error
Err returns the first non-EOF error that was encountered by the iterator.
func (*CsvIterator) Next ¶
func (it *CsvIterator) Next() bool
Next advances the iterator to the next record. It returns true if a record was successfully read, false otherwise (EOF or error). After Next returns false, the Err method should be checked to distinguish between EOF and other errors.
func (*CsvIterator) Record ¶
func (it *CsvIterator) Record() []string
Record returns the current record. It should only be called after a successful call to Next. The returned slice should not be modified by the caller if it's to be reused by the iterator.