Ai
16 Star 69 Fork 54

ShirDon-廖显东/Go语言高级开发与实战-随书代码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
1.2.8-csv.go 908 Bytes
一键复制 编辑 原始数据 按行查看 历史
ShirDon-廖显东 提交于 2021-12-28 09:45 +08:00 . commit
//++++++++++++++++++++++++++++++++++++++++
// 《Go语言高级开发与实战》源码
//++++++++++++++++++++++++++++++++++++++++
// Author:廖显东(ShirDon)
// Blog:https://www.shirdon.com/
// 知乎:https://www.zhihu.com/people/shirdonl
// 公众号:源码大数据
// 仓库地址:https://gitee.com/shirdonl/goAdvanced
// 仓库地址:https://github.com/shirdonl/goAdvanced
//++++++++++++++++++++++++++++++++++++++++
package main
import (
"encoding/csv"
"fmt"
"os"
)
func main() {
file, err := os.Open("./test.csv")
if err != nil {
panic(err)
}
defer file.Close()
reader := csv.NewReader(file)
reader.Comma = ','
reader.FieldsPerRecord = -1
for {
record, e := reader.Read()
if e != nil {
fmt.Println(e)
break
}
fmt.Println(record)
}
}
//[手机号 用户UID Email 用户名]
//[18888888888 2 barry@163.com barry]
//[18888888889 3 wangwu@163.com wangwu]
//EOF
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/shirdonl/goAdvanced.git
git@gitee.com:shirdonl/goAdvanced.git
shirdonl
goAdvanced
Go语言高级开发与实战-随书代码
0f051d9f4e35

搜索帮助