Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ Currently this library supports limited fields
- int
- string
- bool
- float64

13 changes: 12 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package tsv
import (
"encoding/csv"
"errors"
"golang.org/x/text/unicode/norm"
"io"
"reflect"
"strconv"

"golang.org/x/text/unicode/norm"
)

// Parser has information for parser
Expand Down Expand Up @@ -152,6 +153,16 @@ func (p *Parser) Next() (eof bool, err error) {
}
field.SetInt(col)
}
case reflect.Float64:
if record == "" {
field.SetFloat(0)
} else {
col, err := strconv.ParseFloat(record, -1)
if err != nil {
return false, err
}
field.SetFloat(col)
}
default:
return false, errors.New("Unsupported field type")
}
Expand Down