{"id":40901182,"url":"https://github.com/huboh/records","last_synced_at":"2026-01-22T02:32:33.367Z","repository":{"id":45798672,"uuid":"513502481","full_name":"huboh/records","owner":"huboh","description":"A light weight Go package that marshals \u0026 unmarshals CSV records(slice of slice of strings) to/from CSV entries(slice of structs).","archived":false,"fork":false,"pushed_at":"2022-07-18T11:11:27.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T09:56:00.894Z","etag":null,"topics":["csv","csv-mapper","go","go-package","marshaller"],"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/huboh.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":"2022-07-13T11:55:49.000Z","updated_at":"2022-07-16T16:50:02.000Z","dependencies_parsed_at":"2022-07-17T05:46:15.367Z","dependency_job_id":null,"html_url":"https://github.com/huboh/records","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/huboh/records","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huboh%2Frecords","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huboh%2Frecords/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huboh%2Frecords/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huboh%2Frecords/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huboh","download_url":"https://codeload.github.com/huboh/records/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huboh%2Frecords/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28651809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["csv","csv-mapper","go","go-package","marshaller"],"created_at":"2026-01-22T02:32:33.305Z","updated_at":"2026-01-22T02:32:33.358Z","avatar_url":"https://github.com/huboh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Records\n\n## A light weight \u0026 fast Go data marshaler\n\nRecords is a light weight Go package that marshals \u0026 unmarshals CSV records`(slice of slice of strings)` to/from CSV entries`(slice of structs)`.\n\nGo provides the `csv.NewReader` \u0026 `csv.NewWriter` functions to read a CSV file into a *slice of slice of strings* \u0026 to write a *slice of slice of strings* out to a CSV file, without a way to map that data to the fields in a struct. this package add that missing functionality.\n\n## Installation\n\nOnce Go is installed, run the following command to get `Records`.\n\n```bash\ngo get github.com/huboh/records\n```\n\n## Usage\n\n### Unmarshaling CSV records\n\nimport Records\n\n```go\npackage main\n\nimport (\n  \"github.com/huboh/records\"\n)\n```\n\nget csv records from a data source, most likely from a file\n\n```go\nr, err := os.Open(\"\") // import \"os\"\ncsvReader := csv.NewReader(r) // import \"encoding/csv\"\ncsvRecords, err := csvReader.ReadAll() // read csv records\n```\n\nunmarshal csv records. note that unexported fields or fields without csv struct tags are ignored.\n\n```go\n// create a struct that represent your csv data.\ntype CsvFileEntries struct {\n  Age        int    `csv:\"age\"`\n  Name       string `csv:\"name\"`\n  IsEmployee bool   `csv:\"isEmployee\"`\n}\n\nentries := []CsvFileEntries{} // initialize variable to hold csv records\nerr := records.Unmarshal(csvRecords, \u0026entries)\n\nif err != nil \u0026\u0026 errors.Is(err, records.ErrUnSupportedKind) {\n  // encountered fields with unsupported types\n  // supported types are: all int, uint \u0026 float types, bool, string.\n}\n\n// success..  entries =\u003e []CsvFileEntries{{...}}\n```\n\n### Marshaling CSV entries\n\nimport Records\n\n```go\npackage main\n\nimport (\n  \"github.com/huboh/records\"\n)\n```\n\ntransform csv data to csv records. note that fields without csv struct tags are ignored.\n\n```go\n// create a struct that represent your csv data.\ntype CsvFileEntries struct {\n  Age        int    `csv:\"age\"`\n  Name       string `csv:\"name\"`\n  IsEmployee bool   `csv:\"isEmployee\"`\n}\n\nentries := []CsvFileEntries{...}\ncsvRecords, err := records.Marshal(entries) // transform csv data to csv records\n\nif err != nil \u0026\u0026 error.Is(err, records.ErrUnSupportedKind) {\n  // encountered fields with unsupported types\n  // supported types are: all int, uint \u0026 float types, bool, string\n}\n\n// success..  csvRecords =\u003e [][]string{{...}}\n```\n\nafter successfully marshalling your csv data to records, writing the csv records to a file is as easy as:\n\n```go\nw, e := os.Create(\"\")\ncsvWriter := csv.NewWriter(w)\ncsvWriterErr := csvWriter.WriteAll(csvRecords) // writes csv records to file\n```\n\n## Contributions\n\nContributions are welcome to this project to further improve it to suit the public need. I hope you enjoy the simplicity of this package.\n\n## License\n\nThis package is provided under MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuboh%2Frecords","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuboh%2Frecords","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuboh%2Frecords/lists"}