I have been writing, and re-writing as I learn more, a package to parse CSV files. It is based on
http://tools.ietf.org/html/rfc4180 and the design is a finite state machine approach. Perhaps a bit unusual is the choice of a map to model the results since it grows as needed. I notice that there isn't a CSV parser in Go, so I thought I might contribute it. Below are some design elements. Comments?
type CSV struct {
rows map[int] (map[int] string)
rd io.Reader
DEBUG bool
}
Method set:
- func New(in io.Reader) (csv *CSV)
- func (c *CSV) Parse() (m map[int](map[int]string), error os.Error)
- func (m *CSV) String() string
- func (m *CSV) GetMap() map[int](map[int]string)
Todo:
- design writer support
- support macro ="..." style
- ponder CRLF