library: bufio, encoding/csv

This commit is contained in:
xushiwei
2024-07-30 00:44:03 +08:00
parent 679e2d0f6b
commit cc37097164
2 changed files with 32 additions and 0 deletions

View File

@@ -278,6 +278,7 @@ Here are the Go packages that can be imported correctly:
* [flag](https://pkg.go.dev/flag)
* [sort](https://pkg.go.dev/sort)
* [bytes](https://pkg.go.dev/bytes)
* [bufio](https://pkg.go.dev/bufio)
* [strings](https://pkg.go.dev/strings)
* [strconv](https://pkg.go.dev/strconv)
* [path](https://pkg.go.dev/path)
@@ -295,6 +296,7 @@ Here are the Go packages that can be imported correctly:
* [encoding/hex](https://pkg.go.dev/encoding/hex)
* [encoding/base32](https://pkg.go.dev/encoding/base32)
* [encoding/base64](https://pkg.go.dev/encoding/base64)
* [encoding/csv](https://pkg.go.dev/encoding/csv)
* [regexp](https://pkg.go.dev/regexp)
* [regexp/syntax](https://pkg.go.dev/regexp/syntax)

30
_cmptest/csvdemo/csv.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"strings"
)
func main() {
in := `first_name,last_name,username
"Rob","Pike",rob
Ken,Thompson,ken
"Robert","Griesemer","gri"
`
r := csv.NewReader(strings.NewReader(in))
for {
record, err := r.Read()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
fmt.Println(record)
}
}