{"id":16964955,"url":"https://github.com/propensive/caesura","last_synced_at":"2025-03-22T14:31:00.852Z","repository":{"id":39483704,"uuid":"150996141","full_name":"propensive/caesura","owner":"propensive","description":"Simple parsing of CSV into case classes in Scala","archived":false,"fork":false,"pushed_at":"2025-02-12T19:21:35.000Z","size":1947,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-18T11:52:02.096Z","etag":null,"topics":["csv","csv-parser","scala","tsv","tsv-parser"],"latest_commit_sha":null,"homepage":"https://propensive.com/caesura/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/propensive.png","metadata":{"files":{"readme":".github/readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-30T18:51:07.000Z","updated_at":"2025-02-12T19:21:39.000Z","dependencies_parsed_at":"2023-11-16T09:25:21.707Z","dependency_job_id":"db8f4043-925f-4fb7-8995-121ec64b1175","html_url":"https://github.com/propensive/caesura","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcaesura","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcaesura/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcaesura/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcaesura/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/propensive","download_url":"https://codeload.github.com/propensive/caesura/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244971771,"owners_count":20540853,"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","csv-parser","scala","tsv","tsv-parser"],"created_at":"2024-10-13T23:44:41.107Z","updated_at":"2025-03-22T14:31:00.844Z","avatar_url":"https://github.com/propensive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg alt=\"GitHub Workflow\" src=\"https://img.shields.io/github/actions/workflow/status/propensive/caesura/main.yml?style=for-the-badge\" height=\"24\"\u003e](https://github.com/propensive/caesura/actions)\n[\u003cimg src=\"https://img.shields.io/discord/633198088311537684?color=8899f7\u0026label=DISCORD\u0026style=for-the-badge\" height=\"24\"\u003e](https://discord.com/invite/MBUrkTgMnA)\n\u003cimg src=\"/doc/images/github.png\" valign=\"middle\"\u003e\n\n# Caesura\n\n__Simple parsing of CSV into case classes__\n\nCaesura provides an API for reading and writing CSV and TSV.\n\n## Features\n\n- parse CSV and TSV data\n- serialize product-like data (e.g. tuples or case classes) to CSV/TSV rows\n- typeclass-based serialization and deserialization\n- generic derivation of typeclasses for product and coproduct types\n\n\n## Availability\n\n\n\n\n\n\n\n## Getting Started\n\n### Reading CSV Data\n\nCSV data can be read from any value whose type has a `Source` typeclass instance in scope, such as `Text` or a `File` from\n[Galilei](https://github.com/propensive/galilei), passing it to the `Csv.parse` method. For example,\n```scala\nimport caesura.*\nimport galilei.*\nval file: File = ...\nval csv: Csv = Csv.parse(file)\n```\n\nLikewise, TSV data can be read with:\n```scala\nimport caesura.*\nimport galilei.*\nval file: File = ...\nval tsv: Tsv = Tsv.parse(file)\n```\n\n### `Row`, `Csv` and `Tsv` Types\n\nBoth `Csv` and `Tsv` values are nothing more than wrappers around a sequence of `Row` instances, which are themselves `IArray`s\nof `Text` values. While `Row` instances are the same regardless of whether their purpose is for CSV or TSV data, when wrapped\nin a `Csv` or `Tsv` instance, they become serializable with the appropriate column separator (`','` or `'\\t'`) and escaping.\n\nIndeed, the companion objects `Csv` and `Tsv` are just two instances of the `RowFormat` type with different `separator` values\nand implementations of the `RowFormat#escape` method, and alternative formats may be created by subclassing `RowFormat` and\noverriding parameters.\n\n### Interpreting rows\n\nA `Row` instance may be converted to a case class by calling its `Row#as` method with a target type parameter, for example,\n```scala\nval row: Row = Csv.parseRow(t\"Richard,Smith,38\")\n\ncase class Person(firstName: Text, lastName, Text, age: Int)\nval person: Person = row.as[Person]\n```\nwill instantiate an instance of `Person`, `Person(\"Richard\", \"Smith\", 38)` by associating the positional fields in the case\nclass definition with those in the `Row`, and applying the appropriate conversions to construct parameters of the appropriate\ntypes to instantiate the `Person`. In this example, the `age` field is parsed to construct an `Int`.\n\nIf a case class definition includes a nested case class, for example,\n```scala\ncase class Person(firstName: Text, lastName: Text, age: Int)\ncase class Role(title: Text, person: Person, managerial: Boolean)\n```\nthen the structure would first be flattened, so the order of the positional fields for the `Role` case class would be,\n`title` (0), `person.firstName` (1), `person.lastName` (2), `person.age` (3), and `managerial` (4).\n\nThis means the mapping from rows to case class instances is brittle: an additional field in a nested case class would be\ncertain to break interpretation of rows. But that is unfortunately the nature of working with CSV.\n\nThe `as` method also exists on `Csv` and `Tsv`, and will return a `List` of values of the specified type.\n\n### Serializing to rows\n\n`Csv` and `Tsv` instances may also be serialized to streams of data. Any `Seq[T]` (e.g. `List[T]` or `LazyList[T]`) may be\ntransformed to CSV or TSV by calling the `csv` or `tsv` extension methods on it. For example,\n```scala\nval persons: List[Person] =\n  List(Person(t\"Richard\", t\"Smith\", 38), person2, person3)\n\nval personsTsv: Tsv = persons.tsv\n```\n\n\n\n\n\n\n## Status\n\nCaesura is classified as __fledgling__. For reference, Soundness projects are\ncategorized into one of the following five stability levels:\n\n- _embryonic_: for experimental or demonstrative purposes only, without any guarantees of longevity\n- _fledgling_: of proven utility, seeking contributions, but liable to significant redesigns\n- _maturescent_: major design decisions broady settled, seeking probatory adoption and refinement\n- _dependable_: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version `1.0.0` or later\n- _adamantine_: proven, reliable and production-ready, with no further breaking changes ever anticipated\n\nProjects at any stability level, even _embryonic_ projects, can still be used,\nas long as caution is taken to avoid a mismatch between the project's stability\nlevel and the required stability and maintainability of your own project.\n\nCaesura is designed to be _small_. Its entire source code currently consists\nof 395 lines of code.\n\n## Building\n\nCaesura will ultimately be built by Fury, when it is published. In the\nmeantime, two possibilities are offered, however they are acknowledged to be\nfragile, inadequately tested, and unsuitable for anything more than\nexperimentation. They are provided only for the necessity of providing _some_\nanswer to the question, \"how can I try Caesura?\".\n\n1. *Copy the sources into your own project*\n   \n   Read the `fury` file in the repository root to understand Caesura's build\n   structure, dependencies and source location; the file format should be short\n   and quite intuitive. Copy the sources into a source directory in your own\n   project, then repeat (recursively) for each of the dependencies.\n\n   The sources are compiled against the latest nightly release of Scala 3.\n   There should be no problem to compile the project together with all of its\n   dependencies in a single compilation.\n\n2. *Build with [Wrath](https://github.com/propensive/wrath/)*\n\n   Wrath is a bootstrapping script for building Caesura and other projects in\n   the absence of a fully-featured build tool. It is designed to read the `fury`\n   file in the project directory, and produce a collection of JAR files which can\n   be added to a classpath, by compiling the project and all of its dependencies,\n   including the Scala compiler itself.\n   \n   Download the latest version of\n   [`wrath`](https://github.com/propensive/wrath/releases/latest), make it\n   executable, and add it to your path, for example by copying it to\n   `/usr/local/bin/`.\n\n   Clone this repository inside an empty directory, so that the build can\n   safely make clones of repositories it depends on as _peers_ of `caesura`.\n   Run `wrath -F` in the repository root. This will download and compile the\n   latest version of Scala, as well as all of Caesura's dependencies.\n\n   If the build was successful, the compiled JAR files can be found in the\n   `.wrath/dist` directory.\n\n## Contributing\n\nContributors to Caesura are welcome and encouraged. New contributors may like\nto look for issues marked\n[beginner](https://github.com/propensive/caesura/labels/beginner).\n\nWe suggest that all contributors read the [Contributing\nGuide](/contributing.md) to make the process of contributing to Caesura\neasier.\n\nPlease __do not__ contact project maintainers privately with questions unless\nthere is a good reason to keep them private. While it can be tempting to\nrepsond to such questions, private answers cannot be shared with a wider\naudience, and it can result in duplication of effort.\n\n## Author\n\nCaesura was designed and developed by Jon Pretty, and commercial support and\ntraining on all aspects of Scala 3 is available from [Propensive\nO\u0026Uuml;](https://propensive.com/).\n\n\n\n## Name\n\nA _caesura_ is break or pause in a sentence, often indicated by a comma—the same symbol that is used to indicate breaks in a CSV file.\n\nIn general, Soundness project names are always chosen with some rationale,\nhowever it is usually frivolous. Each name is chosen for more for its\n_uniqueness_ and _intrigue_ than its concision or catchiness, and there is no\nbias towards names with positive or \"nice\" meanings—since many of the libraries\nperform some quite unpleasant tasks.\n\nNames should be English words, though many are obscure or archaic, and it\nshould be noted how willingly English adopts foreign words. Names are generally\nof Greek or Latin origin, and have often arrived in English via a romance\nlanguage.\n\n## Logo\n\nThe logo is a comma, the significant character for separating values in CSV files.\n\n## License\n\nCaesura is copyright \u0026copy; 2025 Jon Pretty \u0026 Propensive O\u0026Uuml;, and\nis made available under the [Apache 2.0 License](/license.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fcaesura","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpropensive%2Fcaesura","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fcaesura/lists"}