{"id":13760490,"url":"https://github.com/metasoarous/semantic-csv","last_synced_at":"2025-04-12T16:36:32.775Z","repository":{"id":23050166,"uuid":"26403311","full_name":"metasoarous/semantic-csv","owner":"metasoarous","description":"Higher level tools for working with CSV data and files","archived":false,"fork":false,"pushed_at":"2023-02-15T11:42:50.000Z","size":429,"stargazers_count":254,"open_issues_count":22,"forks_count":22,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-10-13T10:28:28.417Z","etag":null,"topics":["clojure","csv","parsing"],"latest_commit_sha":null,"homepage":"http://metasoarous.github.io/semantic-csv","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metasoarous.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-11-09T17:34:48.000Z","updated_at":"2024-08-08T15:17:39.000Z","dependencies_parsed_at":"2024-01-15T04:11:19.291Z","dependency_job_id":null,"html_url":"https://github.com/metasoarous/semantic-csv","commit_stats":{"total_commits":190,"total_committers":13,"mean_commits":"14.615384615384615","dds":"0.20526315789473681","last_synced_commit":"10f436bacf2ca9ed2f22ffbbecea6467ba20c2e4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metasoarous%2Fsemantic-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metasoarous%2Fsemantic-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metasoarous%2Fsemantic-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metasoarous%2Fsemantic-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metasoarous","download_url":"https://codeload.github.com/metasoarous/semantic-csv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248597377,"owners_count":21130865,"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":["clojure","csv","parsing"],"created_at":"2024-08-03T13:01:11.372Z","updated_at":"2025-04-12T16:36:32.750Z","avatar_url":"https://github.com/metasoarous.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# Semantic CSV\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/metasoarous/semantic-csv?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n**A Clojure library for higher level CSV parsing/processing functionality.**\n\nThe two most popular CSV parsing libraries for Clojure presently - `clojure/data.csv` and `clojure-csv` -\nconcern themselves only with the _syntax_ of CSV;\nThey take CSV text, transform it into a collection of vectors of string values, and that's it.\nSemantic CSV takes the next step by giving you tools for addressing the _semantics_ of your data, helping\nyou put it in a form that better reflects what it represents.\n\nSee the [introductory blog post](http://www.metasoarous.com/presenting-semantic-csv) for more information on the\ndesign philosophy.\n\n\n## Features\n\n* Absorb header row as a vector of column names, and return remaining rows as maps of `column-name -\u003e row-val`\n* Write from a collection of maps, given a header\n* Apply casting/formatting functions by column name, while reading or writing\n* Remove commented out lines (by default, those starting with `#`)\n* Compatible with any CSV parsing library returning/writing a sequence of row vectors\n* Transducer versions of all the main functions by requiring `semantic-csv.transducers` instead of `semantic-csv.core`\n* (UNTESTED) Cljs compatibility\n* (SOON) A \"sniffer\" that reads in N lines, and uses them to guess column types\n\n## Structure\n\nSemantic CSV is structured around a number of composable processing functions for transforming data as it\ncomes out of or goes into a CSV file.\nThis leaves room for you to use whatever parsing/formatting tools you like, reflecting a nice decoupling\nof grammar and semantics.\nHowever, a couple of convenience functions are also provided which wrap these individual steps\nin an opinionated but customizable manner, helping you move quickly while prototyping or working at the\nREPL.\n\n\n## Installation\n\nAssuming you're using Leiningen, just add the following to your dependencies:\n\n[![Clojars Project](http://clojars.org/semantic-csv/latest-version.svg)](http://clojars.org/semantic-csv)\n\nNote that this release is still in alpha and is subject to change.\nIf you would like a stable release, please use 0.1.0 (and note that 0.2.0 was an accidental release and was supposed to be alpha).\nWe're hoping to have a stable 0.2.1 release soon.\n\n\n## Usage\n\nPlease see [metasoarous.github.io/semantic-csv](http://metasoarous.github.io/semantic-csv) for complete documentation.\n\nSemantic CSV _emphasizes_ a number of individual processing functions which can operate on the output of a syntactic csv parser such as `clojure.data.csv` or `clojure-csv`.\nThis reflects a nice decoupling of grammar and semantics, in an effort to make this library as composable and interoperable as possible.\n\n```clojure\n=\u003e (require '[clojure.java.io :as io]\n            '[clojure-csv.core :as csv]\n            '[semantic-csv.core :as sc])\n            \n=\u003e (with-open [in-file (io/reader \"test/test.csv\")]\n     (-\u003e\u003e\n       (csv/parse-csv in-file)\n       (sc/remove-comments)\n       (sc/mappify)\n       (sc/cast-with {:this -\u003eint})\n       doall))\n\n({:this 1, :that \"2\", :more \"stuff\"}\n {:this 2, :that \"3\", :more \"other yeah\"})\n```\n\nHowever, some opinionated, but configurable convenience functions are also provided.\n\n```clojure\n(with-open [in-file (io/reader \"test/test.csv\")]\n  (doall\n    (sc/process (parse-csv in-file))))\n```\nAnd for the truly irreverent... (who don't need _computer_ laziness):\n\n```clojure\n(sc/slurp-csv \"test/test.csv\")\n```\n### Writing CSV data\n\nAs with the input processing functions, the writer processing functions come in modular pieces you can use as you see fit.\nThis time let's use `clojure/data.csv`:\n\n```clojure\n(require '[semantic-csv.core :as sc]\n         '[clojure.data.csv :as cd-csv])\n\n(def data [{:this 1, :that \"2\", :more \"stuff\"}\n           {:this 2, :that \"3\", :more \"other yeah\"}])\n\n(with-open [out-file (io/writer \"test.csv\")]\n  (-\u003e\u003e data\n       (sc/cast-with {:this #(-\u003e % float str)})\n       sc/vectorize\n       (cd-csv/write-csv out-file)))\n```\n\nAnd again, as with the input processing functions, here we also provide a quick and dirty, opinionated convenience function for automating some of this:\n\n```clojure\n(sc/spit-csv \"test2.csv\"\n          {:cast-fns {:this #(-\u003e % float str)}}\n          data)\n```\n\nAnd there you have it.\n\n\n## Transducer API\n\nThere is now a transducer API available under the `semantic-csv.transducers` namespace.\nThis API is now (or will soon be) in public alpha.\nThe API is still subject to change, but we would greatly appreciate feedback.\n\nIn particular, we'd appreciate the following feedback:\n \n* should transducers hook up differently to io? io is sort of a \"reducible\" context...\n* how should the namespaces be organized? the transformer versions current live in a mirror api as the core api.\n\nPlease see [metasoarous.github.io/semantic-csv](http://metasoarous.github.io/semantic-csv#transducers) for complete documentation.\n\n\n## Contributing\n\nFeel free to submit a pull request.\nIf you're looking for things to help with, please take a look at the [GH issues](https://github.com/metasoarous/semantic-csv/issues) page.\nContributing to the issues with comments, feedback, or requests is also greatly appreciated.\n\n\n## Contributors\n\nFor a complete list of contributors, see [the GH contributors page](https://github.com/metasoarous/semantic-csv/graphs/contributors).\n\nOf particular note, however:\n\n* [Mark Hinshaw (@mahinshaw)](https://github.com/mahinshaw): Mark has been a major help on many fronts, but most notably for pushing forward the transducers and cljs compatibility work.\n* [Simon Belak (@sbelak)](https://github.com/sbelak): Helped make casting functionality more robust.\n* [Ben Rosas (@ballPointPenguin)](https://github.com/ballPointPenguin): Ben helped set up some of the early testing.\n\n\n## License\n\nCopyright © 2014-2017 Christopher Small\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetasoarous%2Fsemantic-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetasoarous%2Fsemantic-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetasoarous%2Fsemantic-csv/lists"}