| CARVIEW |
Select Language
HTTP/1.1 200 OK
Connection: keep-alive
Server: nginx/1.24.0 (Ubuntu)
Content-Type: text/html; charset=utf-8
Cache-Control: public, max-age=300
Content-Encoding: gzip
Via: 1.1 varnish, 1.1 varnish
Accept-Ranges: bytes
Age: 0
Date: Fri, 16 Jan 2026 06:31:51 GMT
X-Served-By: cache-dfw-kdfw8210151-DFW, cache-bom-vanm7210058-BOM
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1768545111.201859,VS0,VE301
Vary: Accept, Accept-Encoding
transfer-encoding: chunked
lens-csv
lens-csv
Downloads
- lens-csv-0.1.1.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1.0.0, 0.1.1.0 |
|---|---|
| Change log | ChangeLog.md |
| Dependencies | base (>=4.7 && <5), bytestring, cassava, lens [details] |
| License | BSD-3-Clause |
| Copyright | Chris Penner |
| Author | Chris Penner |
| Maintainer | christopher.penner@gmail.com |
| Uploaded | by ChrisPenner at 2020-04-06T00:04:24Z |
| Home page | https://github.com/ChrisPenner/lens-csv#readme |
| Bug tracker | https://github.com/ChrisPenner/lens-csv/issues |
| Source repo | head: git clone https://github.com/ChrisPenner/lens-csv |
| Distributions | LTSHaskell:0.1.1.0, NixOS:0.1.1.0, Stackage:0.1.1.0 |
| Downloads | 1095 total (5 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs uploaded by user Build status unknown [no reports yet] |
Readme for lens-csv-0.1.1.0
[back to package description]lens-csv
- Docs are on Hackage
If you enjoy working with lenses (or need a hand learning how they work) my book Optics By Example is a great place to learn more!
A lensy layer on top of Cassava which affords streaming, traversable, CSV parsing.
Still experimental (but working). Please file an issue if there are features the library doesn't support.
Example:
>>> import Data.ByteString.Lazy as BL
>>> myCsv <- BL.readFile "./data/simple.csv"
>>> myCsv ^.. namedCsv . taking 2 rows . column @String "state_code"
[ "NY"
, "CA"
]
>>> myCsv ^.. namedCsv . taking 2 rows . _NamedRecord @(M.Map String String)
[ fromList [("population","19540000"), ("state_code","NY")]
, fromList [("population","39560000"), ("state_code","CA")]
]
-- For csv files without headers
>>> myCsv ^.. csv . taking 2 rows . _Record @[String]
[ ["state_code", "population"]
, ["NY" , "19540000"]
]
-- 'column' infers whether it's a named or unnamed csv and accepts the appropriate index type (either ByteString or Int)
>>> myCsv ^.. csv . rows . column @Int 1
[19540000,39560000]
-- Use traversals to edit cells 'in-place' (add 1337 to California's population)
>>> BL.putStrLn $ myCsv & namedCsv . row 1 . column @Int "population" +~ 1337
state_code,population
NY,19540000
CA,39561337
