Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #244 from yuce/doc-updates
Browse files Browse the repository at this point in the history
Updated exports doc
  • Loading branch information
yuce authored Jun 25, 2019
2 parents 8b1c39b + 019bbc5 commit a8834c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ See: [CHANGELOG](CHANGELOG.md)

## Requirements

* Go 1.10 and higher
* Go 1.12 and higher.

## Install

Expand Down
10 changes: 7 additions & 3 deletions docs/imports-exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,20 @@ close(statusChan)

## Exporting Data

You can export a field from Pilosa using `client.ExportField` function which returns a `ColumnIterator`. Use the `NextRecord` function of this iterator to receive all columns for the specified field. When there are no more columns, `io.EOF` is returned.
You can export a field from Pilosa using `client.ExportField` function which returns an `io.Reader`. Wrap that with `csv.NewColumnIterator` or `csv.NewValueIterator` (for int fields) to get a `csv.Iterator` which iterates over CSV lines. `csv.NewColumnIterator` requires specifying a format, like `csv.RowIDColumnID`, `csv.ColumnKey`, etc. See [Importing Data](#importing-data) for all valid formats. Use the `NextRecord` function of this iterator to receive all columns for the specified field. When there are no more columns, `io.EOF` is returned.

Here's sample code for exporting a field:

```go
iterator, err := client.ExportField(field)
import "gihub.com/pilosa/go-pilosa/csv"

...

reader, err := client.ExportField(field)
if err != nil {
log.Fatal(err)
}

iterator := csv.NewColumnIterator(csv.RowIDColumnID, reader)
columns := []pilosa.Column{}
for {
record, err := iterator.NextRecord()
Expand Down

0 comments on commit a8834c1

Please sign in to comment.