{"modulePath":"github.com/rendis/devtoolkit","version":"v1.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package csv\n\n## Types\n\n```go\ntype Reader interface {\n\t// SetHeader sets the header of the CSV file.\n\tSetHeader(header []string)\n\n\t// Iterator returns a RowIterator for iterating over rows.\n\tIterator() RowIterator\n\n\t// GetHeaders returns the headers of the CSV file.\n\tGetHeaders() []string\n\n\t// TotalRows returns the total number of rows in the CSV file.\n\tTotalRows() int\n\n\t// GroupByColumnIndex groups rows by the value at the specified column index.\n\tGroupByColumnIndex(columnIndex int) map[string][]Row\n\n\t// GroupByColumnIndexes groups rows by the values at the specified column indexes.\n\tGroupByColumnIndexes(columnIndexes ...int) map[string][]Row\n\n\t// GroupByColumnName groups rows by the value of the specified column name.\n\tGroupByColumnName(columnName string) map[string][]Row\n\n\t// GroupByColumnNames groups rows by the values of the specified column names.\n\tGroupByColumnNames(columnNames ...string) map[string][]Row\n\n\t// GetRow returns the row at the specified index.\n\tGetRow(index int) (Row, bool)\n\n\t// RowToObjet converts the row at the specified index to the specified object.\n\tRowToObjet(index int, obj any) (bool, error)\n\n\t// GetNextIndex returns the next index based on the current index and cycle option.\n\tGetNextIndex(currentIndex int, cycle bool) int\n\n\t// ToObjects converts all rows to the specified slice of objects.\n\tToObjects(objs []any) error\n}\n```\nReader defines the interface for reading CSV files and provides various methods to work with the data.\n\n```go\nfunc NewCSVReader(r io.Reader, optFns ...func(*ReaderOptions)) (Reader, error)\n```\nNewCSVReader creates a new CSV Reader from an io.Reader with optional ReaderOptions.\n\n```go\nfunc NewCSVReaderFromPath(path string, optFns ...func(*ReaderOptions)) (Reader, error)\n```\nNewCSVReaderFromPath creates a new CSV Reader from a file path with optional ReaderOptions.\n\n```go\ntype ReaderOptions struct {\n\tNoHeader  bool\n\tSeparator ReaderSeparator\n}\n```\nReaderOptions holds options for configuring the CSV Reader.\n\n```go\ntype ReaderSeparator rune\n```\nReaderSeparator defines the type for the separator used in the CSV file.\n\n```go\nconst (\n\t// CommaSeparator is used to separate fields with a comma.\n\tCommaSeparator ReaderSeparator = ','\n\n\t// SemicolonSeparator is used to separate fields with a semicolon.\n\tSemicolonSeparator ReaderSeparator = ';'\n\n\t// TabSeparator is used to separate fields with a tab.\n\tTabSeparator ReaderSeparator = '\\t'\n\n\t// PipeSeparator is used to separate fields with a pipe.\n\tPipeSeparator ReaderSeparator = '|'\n)\n```\n\n```go\nfunc ToReaderSeparator(separator string) (ReaderSeparator, bool)\n```\nToReaderSeparator converts a string to a ReaderSeparator.\n\n```go\ntype Row interface {\n\t// Value returns the value of the specified column name.\n\tValue(columnName string) (string, bool)\n\n\t// Fields returns the fields of the row.\n\tFields() []*RowField\n\n\t// Values returns the values of the row.\n\tValues() []string\n\n\t// AsMap returns the row as a map with column names as keys.\n\tAsMap() map[string]string\n\n\t// LineNumber returns the line number of the row in the CSV file.\n\tLineNumber() int\n\n\t// ToObject converts the row to the specified object.\n\tToObject(obj any) error\n}\n```\nRow defines the interface for a row in the CSV file.\n\n```go\ntype RowField struct {\n\tName  string `json:\"name\" bson:\"name\"`\n\tValue string `json:\"value\" bson:\"value\"`\n}\n```\nRowField represents a field in a row with a name and value.\n\n```go\ntype RowIterator func(yield func(Row) bool)\n```\nRowIterator defines a function type for iterating over rows.\n\n","path":"github.com/rendis/devtoolkit/reader/csv","name":"csv","synopsis":"","isRedistributable":true}
