Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVFileOutput ¶
type CSVFileOutput struct {
ListOfOutputFiles []string
// contains filtered or unexported fields
}
CSVFileOutput is a Writer that outputs to a OS file that rotates.
func NewCSVFileOutput ¶
func NewCSVFileOutput(log logger.Logger, outputDirectory string, fileNamePrefix string, fileNameExtension string, maxFileRows int, maxFileBytes int, useGzip bool) CSVFileOutput
NewCSVFileOutput creates a new CSV file struct. Supply a valid directory or empty string to use default ioutil.TempDir(). Set maxFileRows to the number of rows you want in the CSV file (excluding the header) or 0 to only generate file. Set maxFileBytes to the approx number of bytes you want in the CSV file - only checked per row written. Setting maxFileBytes > 0 will cause each row to be flushed to the CSV file so this causes slower performance. Setting useGzip will use gzip compression and make the extension end with '.gzip' (overriding any supplied alternatives like '.gz').
func (*CSVFileOutput) Cleanup ¶
func (f *CSVFileOutput) Cleanup()
Cleanup can be deferred by the caller to flush the CSV Writer and close the OS file.
func (*CSVFileOutput) MustWriteToCSV ¶
func (f *CSVFileOutput) MustWriteToCSV(record []string) (fileName string)
MustWriteToCSV writes record to the CSV file. Return fileName if a new file is created else empty string "".
func (*CSVFileOutput) SetHeader ¶
func (f *CSVFileOutput) SetHeader(record []string)
SetHeader will store the supplied record for output in each created CSV file.
func (*CSVFileOutput) Write ¶
func (f *CSVFileOutput) Write(p []byte) (n int, err error)
Write uses os.File.Write to write to the file so this struct still implements the core io.Writer interface. Maintains a counter of the number of bytes written to the CSV file. Signals that we need to rotate the CSV file if f.maxFileBytes > 0.