gocarina / gocsv

The GoCSV package aims to provide easy CSV serialization and deserialization to the golang programming language
MIT License
1.99k stars 245 forks source link

Marshal and Unmarshal arrays and slices to and from multiple columns #207

Closed acls closed 2 years ago

acls commented 2 years ago

Fixes #166 and #196

This adds a new tag csv[] that is used to specify the number of items to include. eg:

type SliceStructSample struct {
    Slice       []SliceStruct  `csv:"slice" csv[]:"2"`
}

type SliceStruct struct {
    String string  `csv:"string"`
    Float  float64 `csv:"float"`
}

When marshaling/unmarshaling SliceStructSample the following headers will be used:

slice[0].string,slice[0].float,slice[1].string,slice[1].float