{"id":18345097,"url":"https://github.com/chrispenner/lens-csv","last_synced_at":"2025-04-06T08:31:30.489Z","repository":{"id":56845514,"uuid":"224320307","full_name":"ChrisPenner/lens-csv","owner":"ChrisPenner","description":"Lensy interface for parsing CSV's","archived":false,"fork":false,"pushed_at":"2020-10-20T01:26:26.000Z","size":125,"stargazers_count":41,"open_issues_count":2,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-26T02:02:37.490Z","etag":null,"topics":["csv-parsing","hacktoberfest","lenses","optics"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChrisPenner.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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":"2019-11-27T01:42:12.000Z","updated_at":"2023-03-06T15:40:56.000Z","dependencies_parsed_at":"2022-09-17T21:54:53.092Z","dependency_job_id":null,"html_url":"https://github.com/ChrisPenner/lens-csv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPenner%2Flens-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPenner%2Flens-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPenner%2Flens-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisPenner%2Flens-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChrisPenner","download_url":"https://codeload.github.com/ChrisPenner/lens-csv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223245094,"owners_count":17112572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-parsing","hacktoberfest","lenses","optics"],"created_at":"2024-11-05T21:07:14.149Z","updated_at":"2024-11-05T21:07:15.163Z","avatar_url":"https://github.com/ChrisPenner.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lens-csv\n\n* Docs are on [Hackage](http://hackage.haskell.org/package/lens-csv)\n\nIf you enjoy working with lenses (or need a hand learning how they work) my book [Optics By Example](https://leanpub.com/optics-by-example/) is a great place to learn more!\n\n[![Optics By Example](./optics-by-example.png)](https://leanpub.com/optics-by-example/)\n\nA lensy layer on top of Cassava which affords streaming, traversable, CSV parsing.\n\nStill experimental (but working). Please file an issue if there are features the library doesn't support.\n\nExample:\n\n```haskell\n\u003e\u003e\u003e import Data.ByteString.Lazy as BL\n\u003e\u003e\u003e myCsv \u003c- BL.readFile \"./data/simple.csv\"\n\u003e\u003e\u003e myCsv ^.. namedCsv . taking 2 rows . column @String \"state_code\" \n[ \"NY\"\n, \"CA\"\n]\n\n\u003e\u003e\u003e myCsv ^.. namedCsv . taking 2 rows . _NamedRecord @(M.Map String String)\n[ fromList [(\"population\",\"19540000\"), (\"state_code\",\"NY\")]\n, fromList [(\"population\",\"39560000\"), (\"state_code\",\"CA\")]\n]\n\n-- For csv files without headers\n\u003e\u003e\u003e myCsv ^.. csv . taking 2 rows . _Record @[String]\n[ [\"state_code\", \"population\"]\n, [\"NY\"        , \"19540000\"]\n]\n\n-- 'column' infers whether it's a named or unnamed csv and accepts the appropriate index type (either ByteString or Int)\n\u003e\u003e\u003e myCsv ^.. csv . rows . column @Int 1\n[19540000,39560000]\n\n-- Use traversals to edit cells 'in-place' (add 1337 to California's population)\n\u003e\u003e\u003e BL.putStrLn $ myCsv \u0026 namedCsv . row 1 . column @Int \"population\" +~ 1337\nstate_code,population\nNY,19540000\nCA,39561337\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispenner%2Flens-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrispenner%2Flens-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispenner%2Flens-csv/lists"}