title: Read a CSV line by line and unmarshal it to a struct
body: <p>I have a 8 gigs CSV file that i need to unmarshal to a list of struct</p>
  <pre><code>package main
  
  import (
      &quot;encoding/csv&quot;
      &quot;fmt&quot;
      &quot;io&quot;
      &quot;os&quot;
  
      gocsv &quot;github.com/gocarina/gocsv&quot;
      dto &quot;github.com/toto/GeoTransport/import/dto&quot;
  )
  
  // Put in parameter json the csv names
  func importAdresse() {
      var adressesDB []dto.GeoAdresse
      clientsFile, err := os.OpenFile(&quot;../../../data/geo/public.geo_adresse.csv&quot;, os.O_RDWR|os.O_CREATE, os.ModePerm)
      if err != nil {
          panic(err)
      }
      gocsv.SetCSVReader(func(in io.Reader) gocsv.CSVReader {
          r := csv.NewReader(in)
          r.Comma = ';'
          return r // Allows use pipe as delimiter
      })
      if err = gocsv.UnmarshalFile(clientsFile, &amp;adressesDB); err != nil { // Load clients from file
          panic(err)
      }
      var i int
      i = 0
      for _, adresse := range adressesDB {
          fmt.Println(&quot;adresse.Numero&quot;)
          fmt.Printf(&quot;%+v\n&quot;, adresse)
          fmt.Println(adresse.Numero)
          i++
          if i == 3 {
              break
          }
      }
  }
  
  func init() {
  }
  
  func main() {
      importAdresse()
  }
  </code></pre>
  <p>Actually I am using go csv to unmarshall it but I have some memory error.</p>
  <p>The program quit because it does not have enough ram.</p>
  <p>I would like to know how to read the csv line by line and unmarshal it to a struct.</p>
  <p>One of the solution will be to split the CSV file with some unix command.</p>
  <p>But I would like to know how to do it with only Go.</p>