-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update read to use iter.Seq2 * update Writer to define and write header at runtime * docs --------- Co-authored-by: sfomuseumbot <sfomuseumbot@localhost>
- Loading branch information
1 parent
5e111d8
commit c109999
Showing
7 changed files
with
190 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,2 @@ | ||
// package csvdict implements a "dictionary reader" style CSV parser (on top of the default `encoding/csv` package) to return rows a key-value dictionaries rather than lists. | ||
// Example | ||
// | ||
// Reading files | ||
// | ||
// import ( | ||
// "github.com/whosonfirst/go-csvdict" | ||
// "os" | ||
// ) | ||
// | ||
// reader, reader_err := csvdict.NewReaderFromPath("example.csv") | ||
// | ||
// // or maybe you might do | ||
// // reader, err := csvdict.NewReader(os.Stdin) | ||
// | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
// | ||
// for { | ||
// row, err := reader.Read() | ||
// | ||
// if err == io.EOF { | ||
// break | ||
// } | ||
// | ||
// if err != nil { | ||
// return err | ||
// } | ||
// | ||
// value, ok := row["some-key"] | ||
// | ||
// // and so on... | ||
// } | ||
// | ||
// Writing files | ||
// | ||
// import ( | ||
// "github.com/whosonfirst/go-csvdict" | ||
// "os" | ||
// ) | ||
// | ||
// fieldnames := []string{"foo", "bar"} | ||
// | ||
// writer, err := csvdict.NewWriter(os.Stdout, fieldnames) | ||
// | ||
// // or maybe you might do | ||
// // writer, err := csvdict.NewWriterFromPath("new.csv", fieldnames) | ||
// | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
// | ||
// writer.WriteHeader() | ||
// | ||
// row := make(map[string]string) | ||
// row["foo"] = "hello" | ||
// row["bar"] = "world" | ||
// | ||
// // See this? "baz" is not included in the list of fieldnames | ||
// // above so it will be silently ignored and excluded from your | ||
// // CSV file. Perhaps it should trigger an error. It doesn't, today... | ||
// | ||
// row["baz"] = "wub wub wub" | ||
// | ||
// writer.WriteRow(row) | ||
package csvdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/sfomuseum/go-csvdict | ||
module github.com/sfomuseum/go-csvdict/v2 | ||
|
||
go 1.13 | ||
go 1.23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.