Discover Packages
github.com/nickng/csv
package
module
Version:
v0.0.0-...-d251d7b
Opens a new window with list of versions in this module.
Published: Jun 11, 2023
License: Apache-2.0
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
csv
Library to work with CSV files
Expand ▾
Collapse ▴
Documentation
¶
type Reader[T any ] struct {
}
Reader is a structured data reader from CSV.
r, err := NewReader[*exampleType](csv.NewReader(strings.NewReader(exampleCSV)))
if err != nil {
log.Fatal(err)
}
for {
var record exampleType
if err := r.Read(&record); err != nil {
if err == io.EOF {
break
}
log.Fatal(err)
}
fmt.Printf("%+v\n", record)
}
Output:
{Bar:2 Baz:hello Foo:1}
{Bar:2 Baz:world Foo:3}
NewReader creates a new structured data reader from an underlying
raw CSV record reader. It returns error if the generic type T is
not a valid type to stored the parsed data.
Read reads one record as rowPtr.
It returns io.EOF if there's no more record to read.
type Tag struct {
Options string
}
Tag represents a "csv" struct field tag.
For example, `csv:"field_name"` is represented as Tag{FieldName: "field_name"}
ParseTag parses a raw struct tag (`csv:"tag,value,value2"`)
and returns a Tag representing its content.
Source Files
¶
Directories
¶
cmd
gen
Command gen generates code to parse a CSV record to a struct.
Command gen generates code to parse a CSV record to a struct.
Click to show internal directories.
Click to hide internal directories.