Documentation ¶
Index ¶
- Variables
- func OpenFile(path string) (*os.File, error)
- type 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) ColumnFloat64(s string) (float64, error)
- func (r *Rows) ColumnInt64(s string, base int) (int64, 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) ColumnString(s string) (string, 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) Header() ([]string, error)
- func (r *Rows) Next() error
- func (r *Rows) Row() []string
- type RowsReader
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNullPointer = errors.New("null reference instance") ErrNoData = errors.New("no data") 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) WithFieldsPerRecord ¶
WithFieldsPerRecord method sets FieldsPerRecord 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) ColumnFloat64 ¶
ColumnFloat method returns type float64 data in current row.
func (*Rows) ColumnInt64 ¶
ColumnInt method returns type int64 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) ColumnString ¶
ColumnString method returns string data in current row.
func (*Rows) GetFloat64 ¶
GetFloat method returns type float64 data in current row.
type RowsReader ¶
RowsReader is interface type for reading columns in a row.