-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow2003_test.go
More file actions
46 lines (37 loc) · 931 Bytes
/
show2003_test.go
File metadata and controls
46 lines (37 loc) · 931 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package dbf
import (
"os"
"testing"
"fmt"
)
func TestRead(t *testing.T) {
f, err := os.Open("./show2003.dbf")
// f, err := os.Open("./sjshq.dbf")
if err != nil {
t.Fatal(err)
}
dbr, err := NewReader(f)
if err != nil {
t.Fatal(err)
}
fmt.Printf("Mod date: %d-%d-%d\n", dbr.year, dbr.month, dbr.day)
fmt.Printf("RecordLen:%d\n", dbr.recordlen)
fmt.Printf("RecordNum:%d\n", dbr.Length)
field_names := dbr.FieldNames()
for i, name := range field_names {
fmt.Print(name, ":")
fmt.Printf("%s", string(dbr.fields[i].Type))
fmt.Print(":", dbr.fields[i].Len, ":", dbr.fields[i].DecimalPlaces, ",")
}
fmt.Println("--->")
//rec, e := dbr.Read(0)
//fmt.Println(rec, e, i)
for i := uint32(0); i < uint32(dbr.Length) ; i++ {
record, err := dbr.Read(i)
if err != nil && err.Error() == "EOF" {
break
}
fmt.Print(i, ": ", err)
fmt.Println(record)
}
}