Documentation ¶
Index ¶
- Variables
- func OpenFile(path string) (*os.File, error)
- type Reader
- func (r *Reader) Close() error
- func (r *Reader) LazyQuotes() bool
- func (r *Reader) Read() ([]string, error)
- func (r *Reader) TrimSpace() bool
- func (r *Reader) WithComma(c rune) *Reader
- func (r *Reader) WithFieldsPerRecord(size int) *Reader
- func (r *Reader) WithLazyQuotes(mode bool) *Reader
- func (r *Reader) WithTrimLeadingSpace(mode bool) *Reader
- func (r *Reader) WithTrimSpace(mode bool) *Reader
- type Rows
- func (r *Rows) Close() error
- func (r *Rows) Column(s string) string
- func (r *Rows) ColumnBool(s string) (bool, error)
- func (r *Rows) ColumnByte(s string, base int) (byte, error)
- func (r *Rows) ColumnFloat64(s string) (float64, error)
- func (r *Rows) ColumnInt16(s string, base int) (int16, error)
- func (r *Rows) ColumnInt32(s string, base int) (int32, error)
- func (r *Rows) ColumnInt64(s string, base int) (int64, error)
- func (r *Rows) ColumnInt8(s string, base int) (int8, error)
- func (r *Rows) ColumnNullBool(s string) (sql.NullBool, error)
- func (r *Rows) ColumnNullByte(s string, base int) (sql.NullByte, error)
- func (r *Rows) ColumnNullFloat64(s string) (sql.NullFloat64, error)
- func (r *Rows) ColumnNullInt16(s string, base int) (sql.NullInt16, error)
- func (r *Rows) ColumnNullInt32(s string, base int) (sql.NullInt32, error)
- func (r *Rows) ColumnNullInt64(s string, base int) (sql.NullInt64, error)
- func (r *Rows) ColumnNullString(s string) (sql.NullString, error)
- func (r *Rows) ColumnNullTime(s, layout string) (sql.NullTime, error)
- func (r *Rows) ColumnString(s string) (string, error)
- func (r *Rows) ColumnTime(s, layout string) (time.Time, error)
- func (r Rows) Get(i int) string
- func (r *Rows) GetBool(i int) (bool, error)
- func (r *Rows) GetFloat64(i int) (float64, error)
- func (r *Rows) GetInt64(i int, base int) (int64, error)
- func (r *Rows) GetString(i int) (string, error)
- func (r *Rows) GetTime(i int, layout string) (time.Time, error)
- func (r *Rows) Header() ([]string, error)
- func (r *Rows) LazyQuotes() bool
- func (r *Rows) Next() error
- func (r *Rows) Row() []string
- func (r *Rows) TrimSpace() bool
- type RowsReader
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNullPointer = errors.New("null reference instance") ErrNullValue = errors.New("null value") ErrInvalidRecord = errors.New("invalid record") ErrOutOfIndex = errors.New("out of index") ErrInvalidSheetName = errors.New("invalid sheet name in Excel data") ErrInvalidExcelData = errors.New("invalid Excel data") )
Functions ¶
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is class of CSV reader
func New ¶
New function creates a new Reader instance.
Example ¶
package main import ( "fmt" "github.com/goark/csvdata" ) func main() { file, err := csvdata.OpenFile("testdata/sample.csv") if err != nil { fmt.Println(err) return } rc := csvdata.NewRows(csvdata.New(file), true) defer rc.Close() if err := rc.Next(); err != nil { fmt.Println(err) return } fmt.Println(rc.Column("name")) }
Output: Mercury
func (*Reader) LazyQuotes ¶ added in v0.6.0
LazyQuotes returns LazyQuotes option.
func (*Reader) WithFieldsPerRecord ¶
WithFieldsPerRecord method sets FieldsPerRecord property.
func (*Reader) WithLazyQuotes ¶ added in v0.6.0
WithLazyQuotes method sets LazyQuotes property.
func (*Reader) WithTrimLeadingSpace ¶ added in v0.6.0
WithTrimLeadingSpace method sets TrimLeadingSpace property.
func (*Reader) WithTrimSpace ¶ added in v0.7.0
WithTrimSpace method sets trimSpace and TrimLeadingSpace property.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is a accesser for row-column data set.
func NewRows ¶
func NewRows(rr RowsReader, headerFlag bool) *Rows
func (*Rows) ColumnBool ¶
ColumnBool method returns type bool data in current row.
func (*Rows) ColumnByte ¶ added in v0.6.0
ColumnInt16 method returns type int16 data in current row.
func (*Rows) ColumnFloat64 ¶
ColumnFloat method returns type float64 data in current row.
func (*Rows) ColumnInt16 ¶ added in v0.6.0
ColumnInt16 method returns type int16 data in current row.
func (*Rows) ColumnInt32 ¶ added in v0.6.0
ColumnInt32 method returns type int32 data in current row.
func (*Rows) ColumnInt64 ¶
ColumnInt64 method returns type int64 data in current row.
func (*Rows) ColumnInt8 ¶ added in v0.6.0
ColumnInt8 method returns type int8 data in current row.
func (*Rows) ColumnNullBool ¶
ColumnNullBool method returns sql.NullBool data in current row.
func (*Rows) ColumnNullByte ¶
ColumnNullByte method returns sql.NullByte data in current row.
func (*Rows) ColumnNullFloat64 ¶
func (r *Rows) ColumnNullFloat64(s string) (sql.NullFloat64, error)
ColumnNullFloat64 method returns sql.NullFloat64 data in current row.
func (*Rows) ColumnNullInt16 ¶
ColumnNullInt16 method returns sql.NullFloat64 data in current row.
func (*Rows) ColumnNullInt32 ¶
ColumnNullInt32 method returns sql.NullInt32 data in current row.
func (*Rows) ColumnNullInt64 ¶
ColumnNullInt64 method returns sql.NullInt64 data in current row.
func (*Rows) ColumnNullString ¶
func (r *Rows) ColumnNullString(s string) (sql.NullString, error)
ColumnNullString method returns ql.NullString data in current row.
func (*Rows) ColumnNullTime ¶ added in v0.7.0
ColumnNullTime method returns sql.NullTime data in current row.
func (*Rows) ColumnString ¶
ColumnString method returns string data in current row.
func (*Rows) ColumnTime ¶ added in v0.7.0
ColumnTime method returns type ime.Time data in current row.
func (*Rows) GetFloat64 ¶
GetFloat method returns type float64 data in current row.
func (*Rows) LazyQuotes ¶ added in v0.6.0
LazyQuotes returns LazyQuotes option value.