Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CsvFileIterator ¶
type CsvFileIterator struct {
// contains filtered or unexported fields
}
CsvFileIterator make iterating rows from csv file easier, it reads tuple from csv file and turn it into a `map[string]interface{}` for you.
Example CSV format (exported by dbeaver):
"id","name","json","created_at" 123,"foobar","{""url"": ""https://example.com""}","2022-05-05 09:56:43.438000000"
func NewCsvFileIterator ¶
func NewCsvFileIterator(csvPath string) (*CsvFileIterator, errors.Error)
NewCsvFileIterator create a `*CsvFileIterator` based on path to csv file
func NewCsvFileIteratorFromFile ¶
func NewCsvFileIteratorFromFile(csvFile io.ReadCloser) (*CsvFileIterator, errors.Error)
NewCsvFileIteratorFromFile create a `*CsvFileIterator` from a file descriptor
func (*CsvFileIterator) Fetch ¶
func (ci *CsvFileIterator) Fetch() map[string]any
Fetch returns current row as a map
func (*CsvFileIterator) FetchRecords ¶
func (ci *CsvFileIterator) FetchRecords() []*CsvRecord
Fetch returns current row as list of pairs (in order)
func (*CsvFileIterator) GetColumns ¶
func (ci *CsvFileIterator) GetColumns() []string
GetColumns the column names of the CSV file
func (*CsvFileIterator) HasNext ¶
func (ci *CsvFileIterator) HasNext() bool
HasNext returns a boolean to indicate whether there was any row to be `Fetch`
func (*CsvFileIterator) HasNextWithError ¶
func (ci *CsvFileIterator) HasNextWithError() (bool, errors.Error)
HasNextWithError returns a boolean to indicate whether there was any row to be `Fetch`
type CsvFileWriter ¶
type CsvFileWriter struct {
// contains filtered or unexported fields
}
CsvFileWriter make writer for saving csv file easier, it write tuple to csv file
Example CSV format (exported by dbeaver):
"id","name","json","created_at" 123,"foobar","{""url"": ""https://example.com""}","2022-05-05 09:56:43.438000000"
func NewCsvFileWriter ¶
func NewCsvFileWriter(csvPath string, fields []string) (*CsvFileWriter, errors.Error)
NewCsvFileWriter create a `*CsvFileWriter` based on path to saving csv file
func (*CsvFileWriter) Flush ¶
func (ci *CsvFileWriter) Flush()
Flush the wrote data into file physically
func (*CsvFileWriter) Write ¶
func (ci *CsvFileWriter) Write(values []string)
Write the values into csv