Added ToCSV
This commit is contained in:
parent
19f092b899
commit
dfb22d462e
2 changed files with 42 additions and 0 deletions
15
csv_test.go
15
csv_test.go
|
|
@ -1,6 +1,7 @@
|
|||
package scriptx_test
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/bitfield/script"
|
||||
|
|
@ -42,3 +43,17 @@ func ExampleCSVColumn() {
|
|||
// banana
|
||||
// cherry
|
||||
}
|
||||
|
||||
func ExampleToCSV() {
|
||||
script.Slice([]string{
|
||||
"letter fruit word",
|
||||
"a apple alpha",
|
||||
"b banana bravo",
|
||||
"c cherry charlie",
|
||||
}).Filter(scriptx.ToCSV(regexp.MustCompile(`\s+`))).Stdout()
|
||||
// Output:
|
||||
// letter,fruit,word
|
||||
// a,apple,alpha
|
||||
// b,banana,bravo
|
||||
// c,cherry,charlie
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue