Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OldReader ¶
type OldReader struct { // the following are from encoding/csv package and are copied into the underlying csv.Reader Comma rune Comment rune FieldsPerRecord int // we can't implement this without more overhead/synchronization LazyQuotes bool TrailingComma bool TrimLeadingSpace bool ChunkSize int // the # of lines to hand to each goroutine -- default 50 // contains filtered or unexported fields }
OldReader contains all the internals required. Use NewReader(io.OldReader).
func OldNewReader ¶
OldNewReader returns a new Reader that reads from r.
func OldNewReaderSized ¶
NewReader returns a new Reader that reads from r with the chunked size
func (*OldReader) Close ¶
Close will clean up any goroutines that aren't finished. It will also close the underlying Reader if it implements io.ReadCloser
func (*OldReader) Read ¶
Read reads one record from r. The record is a slice of strings with each string representing one field. In the background, the internal io.Reader will be read from ahead of the caller utilizing Read() to pull every row
func (*OldReader) ReadAll ¶
ReadAll reads all the remaining records from r. Each record is a slice of fields. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.
func (*OldReader) Stream ¶
Stream returns a chan of []string representing a row in the CSV file. Lines are sent on the channel in order they were in the source file. The caller must receive all rows and receive the error from the error chan, otherwise the caller must call Close to clean up any goroutines.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
type Writer ¶
type Writer struct { Comma rune // Field delimiter (set to ',' by NewWriter) UseCRLF bool // True to use \r\n as the line terminator ChunkSize int // the # of lines to hand to each goroutine -- default 50 // contains filtered or unexported fields }
A Writer writes records to a CSV encoded file.
As returned by NewWriter, a Writer writes records terminated by a newline and uses ',' as the field delimiter. The exported fields can be changed to customize the details before the first call to Write or WriteAll.
Comma is the field delimiter.
If UseCRLF is true, the Writer ends each record with \r\n instead of \n.
func NewWriterSized ¶
NewWriter returns a new Writer that writes to w with a specific chunkSize. Must call Close when done.
func (*Writer) Close ¶
Close closes the underlying io.Writer if it's also an io.Closer as well as cleaning up all goroutines
func (*Writer) Flush ¶
func (mcw *Writer) Flush()
Flush writes any buffered data to the underlying io.Writer. To check if an error occurred during the Flush, call Error.