{"id":19292399,"url":"https://github.com/foolin/gocsv","last_synced_at":"2026-03-10T00:33:46.443Z","repository":{"id":57484486,"uuid":"50414534","full_name":"foolin/gocsv","owner":"foolin","description":"go csv helper, read csv and unmarshal for struct, map, list.","archived":false,"fork":false,"pushed_at":"2017-02-22T01:28:43.000Z","size":2399,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T07:45:56.595Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foolin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-26T08:24:09.000Z","updated_at":"2023-11-07T06:27:11.000Z","dependencies_parsed_at":"2022-08-26T14:23:50.794Z","dependency_job_id":null,"html_url":"https://github.com/foolin/gocsv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/foolin/gocsv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fgocsv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fgocsv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fgocsv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fgocsv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foolin","download_url":"https://codeload.github.com/foolin/gocsv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fgocsv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30318492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T22:30:36.736Z","updated_at":"2026-03-10T00:33:46.420Z","avatar_url":"https://github.com/foolin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gocsv\n\ngo csv helper, read csv and unmarshal for struct, map, list.\n\nFeatures\n---------\n* Read for struct/map/parser\n* Support generator struct\n* Support encoding\n\nUsage\n---------\n\nInstall:\n\n    go get github.com/foolin/gocsv\n\n\nExample:\n\n```go\n\npackage main\nimport (\n\t\"github.com/foolin/gocsv\"\n\t\"fmt\"\n)\n\n//Goods goods struct for csv\ntype Goods struct {\n\tID   int `csv:\"id\"`\t//id =\u003e ID\n\tName string\t// name =\u003e Name (default, first letter lowercase)\n\tPrice float64 `csv:\"cost\"`\t// rename price =\u003e cost\n}\n\nfunc main() {\n\n\tvar err error\n\n\t//======================= read map[string]interface{} ===================//\n\tfmt.Println(\"\\n------------- read  -------------\")\n\t//datautf8.csv utf8 file\n\tdata, err := gocsv.Read(\"datautf8.csv\", true)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"read error: %v\", err))\n\t\treturn\n\t}\n\tfmt.Printf(\"%#v\\n\", data)\n\n\n\t//======================= read list ===================//\n\tfmt.Println(\"\\n------------- read list  -------------\")\n\tvar list []Goods\n\t//data.csv ANSI(excel default)\n\terr = gocsv.ReadList(\"data.csv\", false, \u0026list)\n\tif err != nil {\n\t\tfmt.Printf(\"read error: %v\", err)\n\t\treturn\n\t}\n\tfmt.Printf(\"%#v\\n\", list)\n\n\n\t//======================= read map ===================//\n\tfmt.Println(\"\\n------------- read map  -------------\")\n\tvar vmap map[int]Goods\n\t//data.csv ANSI(excel default)\n\terr = gocsv.ReadMap(\"data.csv\", false, \"id\", \u0026vmap)\n\tif err != nil {\n\t\tfmt.Printf(\"read error: %v\", err)\n\t\treturn\n\t}\n\tfmt.Printf(\"%#v\\n\", vmap)\n\n\t//======================= read parser ===================//\n\tfmt.Println(\"\\n------------- read parser  -------------\")\n\tline := 1\n\terr = gocsv.ReadRaw(\"data.csv\", false, func(fields []gocsv.Field) error {\n\t\tfmt.Printf(\"-line %v\\n\", line)\n\t\tfor _, f := range fields {\n\t\t\tfmt.Printf(\"%#v\\n\", f)\n\t\t}\n\t\tline = line + 1\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tfmt.Printf(\"read error: %v\", err)\n\t\treturn\n\t}\n\n}\n\n\n\n\n```\n\nCsv:\n\n    Goods Id,Goods Name,Sell Price\n    id,name,cost\n    int,string,float\n    1,Apple iPhone 6s,5999.99\n    2,Other Mobile Phone,699.99\n\n\n\nOutput:\n\n```go\n\n------------- read  -------------\n[]map[string]interface {}{map[string]interface {}{\"id\":1, \"name\":\"Apple iPhone 6s\", \"cost\":5999.99}, map[string]interface {}{\"id\":2, \"name\":\"Other Mobile Phone\", \"cost\":699.99}}\n\n------------- read list  -------------\n[]main.Goods{main.Goods{ID:1, Name:\"Apple iPhone 6s\", Price:5999.99}, main.Goods{ID:2, Name:\"Other Mobile Phone\", Price:699.99}}\n\n------------- read map  -------------\nmap[int]main.Goods{1:main.Goods{ID:1, Name:\"Apple iPhone 6s\", Price:5999.99}, 2:main.Goods{ID:2, Name:\"Other Mobile Phone\", Price:699.99}}\n\n------------- read parser  -------------\n-line 1\ngocsv.Field{Name:\"id\", Value:\"1\", Kind:\"int\"}\ngocsv.Field{Name:\"name\", Value:\"Apple iPhone 6s\", Kind:\"string\"}\ngocsv.Field{Name:\"cost\", Value:\"5999.99\", Kind:\"float\"}\n-line 2\ngocsv.Field{Name:\"id\", Value:\"2\", Kind:\"int\"}\ngocsv.Field{Name:\"name\", Value:\"Other Mobile Phone\", Kind:\"string\"}\ngocsv.Field{Name:\"cost\", Value:\"699.99\", Kind:\"float\"}\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoolin%2Fgocsv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoolin%2Fgocsv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoolin%2Fgocsv/lists"}