On 05/29/2017 07:23 AM, Vikram Rawat wrote:> Can anybody please tell me
how to write GOTA Golang dataframes on a csv...
>
> It's been 2 days I am trying to find a way to write dataframes onto a
> csv. can anybody please help me understand what does this IO.writer
> means and how to use it...
>
> I have given up understanding it...
>
> Please any help will be appriciated.
>

io.Writer is an interface that matches any concrete type that implements
the Write() method:

   https://golang.org/pkg/io/#Writer

os.Create returns a writer that you can use to write to a file like:

  w, err := os.Create("myfile.csv")

and you can write your CSV to it using the WriteCSV() method described
below:

  https://godoc.org/github.com/kniren/gota/dataframe

So based on the documentation, something like the code below should work:

  df := dataframe.LoadRecords(
      [][]string{
          []string{"A", "B", "C", "D"},
          []string{"a", "4", "5.1", "true"},
          []string{"b", "4", "6.0", "true"},
          []string{"c", "3", "6.0", "false"},
          []string{"a", "2", "7.1", "false"},
      },
  )

  w, err := os.Create("myfile.csv")

  if err == nil {
    /* handle os.Create() error here. */
  }

  df.WriteCSV(w)

  ...


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to