{"id":15066965,"url":"https://github.com/chrispomeroyhale/csv-dialect-swift","last_synced_at":"2025-04-10T13:53:45.714Z","repository":{"id":59110678,"uuid":"168103102","full_name":"chrispomeroyhale/csv-dialect-swift","owner":"chrispomeroyhale","description":"DialectalCSV: Multi-dialect CSV parser in Swift for handling different separated value formats. Conforms to Frictionless Data's CSV Dialect spec","archived":false,"fork":false,"pushed_at":"2024-03-16T21:14:20.000Z","size":46,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T04:02:11.126Z","etag":null,"topics":["csv","delimited","dialect","parser","rfc-4180","streaming","swift","swift-package-manager","tsv"],"latest_commit_sha":null,"homepage":"https://frictionlessdata.io/specs/csv-dialect/","language":"Swift","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/chrispomeroyhale.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","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":"2019-01-29T06:36:02.000Z","updated_at":"2024-08-26T15:41:07.000Z","dependencies_parsed_at":"2024-03-17T00:21:14.130Z","dependency_job_id":"2ba8491a-a19b-4e17-b94b-318a33ed00cf","html_url":"https://github.com/chrispomeroyhale/csv-dialect-swift","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"b0e6ba64cf9d529293f0f4d1172d159fa7f813b6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispomeroyhale%2Fcsv-dialect-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispomeroyhale%2Fcsv-dialect-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispomeroyhale%2Fcsv-dialect-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispomeroyhale%2Fcsv-dialect-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrispomeroyhale","download_url":"https://codeload.github.com/chrispomeroyhale/csv-dialect-swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248229201,"owners_count":21068857,"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","delimited","dialect","parser","rfc-4180","streaming","swift","swift-package-manager","tsv"],"created_at":"2024-09-25T01:14:37.986Z","updated_at":"2025-04-10T13:53:45.698Z","avatar_url":"https://github.com/chrispomeroyhale.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DialectalCSV (`csv-dialect-swift`)\n![Build Status](https://github.com/chrispomeroyhale/csv-dialect-swift/actions/workflows/tests.yml/badge.svg?branch=main)\n[![Coverage Status](https://coveralls.io/repos/github/chrispomeroyhale/csv-dialect-swift/badge.svg?branch=main)](https://coveralls.io/github/chrispomeroyhale/csv-dialect-swift?branch=main)\n\nA multi-dialect CSV parser written in Swift for importing and exporting the delectable flavors of comma separated values documents. This library implements [Frictionless Data's CSV Dialect](https://frictionlessdata.io/specs/csv-dialect/) spec which acknowledges that the CSV RFC 4180 is retroactive and that in practice numerous flavors of documents and exporters exist. The library also supports streaming of data incrementally for a low peak memory footprint.\n\nDialectalCSV provides a tiered interface for working with CSV. At its lowest level is a pair of parsers capable of streaming partial data. A higher level interface is available for working with file URLs using `FileHandle` for data streaming. And a convenience class `Document` enables working with in-memory representations.\n\nThe library is backed by a small set of unit tests which provides a basis for regression testing.\n\n## Requirements\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fchrispomeroyhale%2Fcsv-dialect-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/chrispomeroyhale/csv-dialect-swift)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fchrispomeroyhale%2Fcsv-dialect-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/chrispomeroyhale/csv-dialect-swift)\n\n * Source compatible with Swift 4.2 and up\n * Targets Apple platforms, namely macOS and iOS\n * Relies upon `Foundation` and Swift standard library APIs only\n    * Linux support unavailable due to an incomplete `Scanner` implementation in `swift-corelibs-foundation`\n\n## Feature Status\n| CSV Dialect Property  | Status      |\n|:----------------------|:------------|\n| Delimiter             | Available   |\n| Line Terminator       | Available   |\n| Quote Character       | Available   |\n| Double Quote          | Available   |\n| Escape Character      | Available   |\n| Null Sequence         | Available   |\n| Skip Initial Space    | Available   |\n| Header                | Available   |\n| Comment Character     | Unavailable |\n| Case Sensitive Header | *N/A*       |\n\nThis implementation is compatible with `csvddfVersion` 1.2.\n\n## Usage\nFor additional examples take a look at the test cases and consult the interface documentation including the possible error cases that can be thrown.\n\n### Opening a CSV Document in Memory\nOpen a tab separated value (TSV) file from in-memory data:\n\n    import DialectalCSV\n\n    var dialect = Dialect()\n    dialect.delimiter = \"\\t\"\n    dialect.header = false\n    let document = try Document(data: data, dialect: dialect)\n\n### Creating a CSV Document\nCreate a CSV document from Foundation objects and set a custom null sequence pattern for nil values.\n\n    import DialectalCSV\n\n    let headerAndRows = [ [\"name\", \"nickname\"], [\"Nelson Mandela\", \"Madiba\"] ]\n    let document = Document(allRows: headerAndRows)\n    document.records.append([\"Mahatma Gandhi\", nil])\n\n    let outputFileHandle = try FileHandle(forWritingTo: outputURL)\n    var dialect = Dialect()\n    dialect.nullSequence = \"n/a\"\n    try document.export(fileHandle: outputFileHandle, dialect: dialect)\n\n### Converting a CSV Document via Data Streaming\nConvert a CSV document to a tab separated value (TSV). Stream it into a buffer of the default byte length instead of loading it all into memory at once.\n\n    import DialectalCSV\n\n    FileManager.default.createFile(atPath: outputURL.path, contents: nil)\n    let outputFileHandle = try FileHandle(forWritingTo: outputURL)\n    var outputDialect = Dialect()\n    outputDialect.delimiter = \"\\t\"\n    let outputHandler = OutputHandler(fileHandle: outputFileHandle, dialect: outputDialect)\n\n    let inputFileHandle = try FileHandle(forReadingFrom: inputURL)\n    let inputHandler = InputHandler(fileHandle: inputFileHandle, dialect: inputDialect)\n    inputHandler.delegate = outputHandler\n\n    try inputHandler.readToEndOfFile()\n\n## Integrating into Your Project\nThis project is intended to be distributed via Swift Package Manager. Alternative methods are possible if SPM is not an option.\n\n### Xcode via Swift Package Manager (Recommended)\nIn Xcode 11 Swift Package Manager is now integrated into Xcode. Add this package as you would any other Swift package.\n\nThis method was not reliable until about Xcode 11.2. There is no xcodeproj for older versions of Xcode although one can be generated. See the Xcode Subproject option.\n\n### Manual Swift Package Manager (Recommended)\nAdd the following dependency to your `Package.swift`'s `dependencies` and use `DialectalCSV` as the name of the dependency. You may wish to change the branch or use a particular revision.\n\n\t.package(url: \"git@github.com:chrispomeroyhale/csv-dialect-swift.git\", .branch(\"main\"))\n\n### Carthage (Not Recommended)\nWhile Carthage does not officially support Swift Package Manager it is possible to integrate it manually. Create a \"Run Script\" phase and position it to appear before the \"Compile Sources\" phase to automate updating, generating the Xcode project, and building of dependencies. After running the script follow Carthage's documentation for integrating the dependency into your project.\n\n\tcarthage update --no-build\n\n\tpushd \"Carthage/Checkouts/csv-dialect-swift\"\n\tswift package generate-xcodeproj --xcconfig-overrides ./Configuration.xcconfig\n\tpopd\n\n\tcarthage build --cache-builds\n\n### Xcode Subproject (Not Recommended)\nWith this option, first either set up this library with an external tool for managing dependencies (such as git submodules) or commit the library's source directly. Then generate an Xcode project using:\n\n\tswift package generate-xcodeproj --xcconfig-overrides ./Configuration.xcconfig\n\nAdd the generated Xcode project as a subproject and configure your project to use the `DialectalCSV` target dependency along with all the traditional steps for manually integrating a library.\n\nYou may choose to add a \"Run Script\" phase that generates the Xcode project for you, such as:\n\n\tpushd \"Vendors/DialectalCSV\"\n\tif [ ! -f ./csv-dialect-swift.xcodeproj/project.pbxproj ]; then\n\t\tswift package generate-xcodeproj --xcconfig-overrides ./Configuration.xcconfig\n\telse\n\t\techo \"Skipping Xcode project generation for 'DialectalCSV'.\"\n\tfi\n\tpopd\n\nNote that the caveat with this solution is you will still need to remove the generated Xcode project between upgrades which is a potential source of human error such as when switching branches that use different versions of the library.\n\n## License\nLicensed under a 3-clause BSD license. See `License.txt`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispomeroyhale%2Fcsv-dialect-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrispomeroyhale%2Fcsv-dialect-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispomeroyhale%2Fcsv-dialect-swift/lists"}