From 90e267333ac2934f75665575e161ed5d5f29c7f7 Mon Sep 17 00:00:00 2001 From: kewang Date: Thu, 26 May 2016 17:49:09 -0700 Subject: [PATCH 1/2] be able to support float64 --- parser.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/parser.go b/parser.go index b2e29e1..785e993 100644 --- a/parser.go +++ b/parser.go @@ -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 @@ -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") } From 76f15d917d2433c817e305d7197c33206f74baaf Mon Sep 17 00:00:00 2001 From: kewang Date: Thu, 26 May 2016 17:54:35 -0700 Subject: [PATCH 2/2] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 09b36e2..1f8b5e7 100644 --- a/README.md +++ b/README.md @@ -73,4 +73,5 @@ Currently this library supports limited fields - int - string - bool +- float64