Giter VIP home page Giter VIP logo

go-csv-tag's People

Contributors

abtmr avatar adrianmo avatar artonge avatar chenall avatar crazcalm avatar edfungus avatar leftshift avatar meyskens avatar mhewedy avatar mudhoney avatar vector-hector avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-csv-tag's Issues

Fail to load content with trailing spaces

The library fails to parse CSV files that contain lines with trailing spaces. I came across this issue when trying to read a GTFS file using the go-gtfs library.

E.g.:

header1, header2, header3
line1, 1, 1.2                                                                                                                                                                                                                                                                                                                         
line2, 2, 2.3                                                                                                                                                                                                                                                                                                                         
line3, 3, 3.4           

Error produced:

error mapping csv from path csv_files/trailingSpaces.csv:
        ==> error mapping the content to the destination
        ==> line: [line1 1 1.2                ] to slice: {line1 1 0}:
        ==> error parsing float '1.2                ':
        ==> strconv.ParseFloat: parsing "1.2                ": invalid syntax

int64 support.

Hi I was trying to use this package to decode a struct with int64 fields and It wasn't working. There is a simple fix for this in load.go:

func storeValue(rawValue string, valRv reflect.Value) error {
	switch valRv.Kind() {
	case reflect.String:
		valRv.SetString(rawValue)
	case reflect.Int64: // Add this.
		fallthrough
	case reflect.Int:
		value, err := strconv.ParseInt(rawValue, 10, 64)
		if err != nil && rawValue != "" {
			return fmt.Errorf("error parsing int '%v':\n	==> %v", rawValue, err)

		}

New CsvOption - TagKey

It would be nice if we could specify a custom tag key. An example use case is where we might want to make use of existing tags such as json. A working example here

Add way to specify notation to be used for floats

When Dumping structs containing floats, the default representation is used. For high exponents, this is scientific notation, e.g. 1e-06 for 0.000001.

This is incompatible with some specifications that use csv. Currently, there's no way of specifying which representation go-csv-tag should use. Similar situations may arrise for other types, like if an integer should be duped as a hexadeximal value.

Have you tested the LoadFromPath?

First use the example DumpToFile to generate a csv test file, then use LoadFromPath to load this file, panic happened

generated csv file :
name, ID, number
'name1', 1, 1.2

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/artonge/go-csv-tag.mapToDestination(0xc0000c7f48, 0x3, 0x3, 0xc0000b4
330, 0x2, 0x2, 0x4bbf00, 0xc000096560, 0x3, 0xc0000b4330)
E:/Go/gopath/src/github.com/artonge/go-csv-tag/load.go:182 +0xe9f
github.com/artonge/go-csv-tag.LoadFromReader(0x503ac0, 0xc0000ca028, 0x4bbf00, 0
xc000096560, 0xc0000c7f28, 0x1, 0x1, 0xc00008c8f0, 0xc0000a00c0)
E:/Go/gopath/src/github.com/artonge/go-csv-tag/load.go:48 +0x17e
github.com/artonge/go-csv-tag.LoadFromPath(0x4e52c4, 0x11, 0x4bbf00, 0xc00009656
0, 0xc0000c7f28, 0x1, 0x1, 0x0, 0x0)
E:/Go/gopath/src/github.com/artonge/go-csv-tag/load.go:78 +0x10b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.