forked from geofflangdale/simdcsv
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi.go
More file actions
30 lines (24 loc) · 606 Bytes
/
Copy pathapi.go
File metadata and controls
30 lines (24 loc) · 606 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package simdcsv
import "C"
type CSVParser struct {
keys int
rec C.struct_Records
}
// NewCSVParser creates a new parser using k keys.
func NewCSVParser(k int) *CSVParser {
return &CSVParser{
keys: k,
}
}
// Next returns the next row until EOF.
func (c *CSVParser) Next() ([]string, error) {
return getNextRow(&c.rec)
}
// ParseCSVFile parses and load the file into memory. For now that's the only way to utilize SIMD.
func (c *CSVParser) ParseCSVFile(filename string) error {
c.rec = parseCSVFromFile(filename, c.keys)
return nil
}
func (c *CSVParser) FreeRecords() {
freeRecords(c.rec)
}