github.com/verygoodsoftwarenotvirus/cartogopher@v0.0.0-20160213112503-f5fe2b6d4bd1/README.md (about)

     1  
     2  # Cartogopher [![Build Status](https://travis-ci.org/LiterallyElvis/cartogopher.svg?branch=master)](https://travis-ci.org/LiterallyElvis/cartogopher) [![Go Report Card](https://goreportcard.com/badge/github.com/LiterallyElvis/cartogopher)](https://goreportcard.com/report/github.com/LiterallyElvis/cartogopher)
     3  
     4  A super simple library to read CSVs as maps instead of arrays in golang
     5  
     6  ## Usage
     7  
     8  Cartogopher can be used as an augmentor of Go's built in CSV reader.
     9  
    10  The 'Hello World' for cartogopher looks something like this:
    11  
    12      package main
    13  
    14      import (
    15          "encoding/csv"
    16          "github.com/literallyelvis/cartogopher"
    17          "os"
    18      )
    19  
    20      func main(){
    21          file, err := os.Open("whatever.csv")
    22          if err != nil{
    23              // handle error as you please
    24          }
    25  
    26          reader, err := csv.NewReader(file)
    27          if err != nil{
    28              // handle error as you please
    29          }
    30  
    31          myCSV, err := cartogopher.NewReader(reader)
    32          if err != nil{
    33              // handle error as you please
    34          }
    35  
    36          theRestOfTheFile, err := myCSV.Reader.ReadAll()
    37          if err != nil{
    38              // handle error as you please
    39          }
    40          // do things with theRestOfTheFile
    41      }