gocsv.go Simple csv parsing with GO

Recently I was working with csv files in Ruby. Parsing csv files in Ruby code is easy, thanks to Ruby/csv.

Lets try it with golang.

Go seems to be pretty power-packed language for developers. Go, also commonly referred to as golang, is a programming language initially developed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is a statically-typed language with syntax loosely derived from that of C, adding garbage collection, type safety, some dynamic-typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library. And since its from Google, the big giant, Go has built in support for concurrency with go-routines, channels and select.

Lets get to work now.

Here is a sample csv file for tests.
Output:

Advertisements

One thought on “gocsv.go Simple csv parsing with GO

  1. This is a nice little intro into CSV parsing with Go. I hadn't yet come to this son not looked into it at all, seeing it clearly presented was nice. While this is only a sie example it would be nice if the main() could simply handle CLI using the flags package and then have a separate method for the extra set up and the actual parsing.

    I liked seeing this it would be totally awesome if it also demonstrated good coding practice as a side benefit.

    Thanks again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s