csvdata -- Reading CSV Data
This package is required Go 1.16 or later.
Migrated repository to github.com/goark/csvdata
import "github.com/goark/csvdata"
package csvdata_test
import (
"fmt"
"github.com/goark/csvdata"
)
func ExampleNew() {
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
}
package exceldata_test
import (
"fmt"
"github.com/goark/csvdata"
"github.com/goark/csvdata/exceldata"
)
func ExampleNew() {
xlsx, err := exceldata.OpenFile("testdata/sample.xlsx", "")
if err != nil {
fmt.Println(err)
return
}
r, err := exceldata.New(xlsx, "")
if err != nil {
fmt.Println(err)
return
}
rc := csvdata.NewRows(r, true)
defer rc.Close() //dummy
if err := rc.Next(); err != nil {
fmt.Println(err)
return
}
fmt.Println(rc.Column("name"))
// Output:
// Mercury
}
package calcdata_test
import (
"fmt"
"github.com/goark/csvdata"
"github.com/goark/csvdata/calcdata"
)
func ExampleNew() {
ods, err := calcdata.OpenFile("testdata/sample.ods")
if err != nil {
fmt.Println(err)
return
}
r, err := calcdata.New(ods, "")
if err != nil {
fmt.Println(err)
return
}
rc := csvdata.NewRows(r, true)
defer rc.Close() //dummy
if err := rc.Next(); err != nil {
fmt.Println(err)
return
}
fmt.Println(rc.Column("name"))
// Output:
// Mercury
}