{"id":13626381,"url":"https://github.com/brutella/swift-csv","last_synced_at":"2025-04-13T09:32:43.028Z","repository":{"id":136247943,"uuid":"93140190","full_name":"brutella/swift-csv","owner":"brutella","description":"Fast and memory-efficient CSV library in Swift.","archived":false,"fork":false,"pushed_at":"2020-05-11T14:49:10.000Z","size":155,"stargazers_count":85,"open_issues_count":1,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-27T01:35:50.662Z","etag":null,"topics":["csv","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brutella.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-06-02T07:40:06.000Z","updated_at":"2025-01-01T16:51:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"f112209a-c190-4d0e-acfc-62c7e6c19655","html_url":"https://github.com/brutella/swift-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/brutella%2Fswift-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brutella%2Fswift-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brutella%2Fswift-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brutella%2Fswift-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brutella","download_url":"https://codeload.github.com/brutella/swift-csv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248690925,"owners_count":21146232,"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","swift"],"created_at":"2024-08-01T21:02:16.770Z","updated_at":"2025-04-13T09:32:42.378Z","avatar_url":"https://github.com/brutella.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# swift-csv\n\n`swift-csv` is a stream based CSV library written in Swift. It uses `InputStream` to parse a CSV file and `OutputStream` to write CSV data to a file.\nThis way it doesn't keep everything in memory while working with big CSV files. It also supports [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) for UTF-8, UTF-16 and UTF-32 text encodings.\n\n`swift-csv` is battle tested in the CSV import and export of [Finances](https://hochgatterer.me/finances/).\n\n# Features\n\n- Stream based CSV parser and writer\n- Complete documentation\n- Unit tested\n\n# Usage\n\n## Parser\n\n```swift\nlet stream = InputStream(...)\n\n// Define the delimeter and encoding of the CSV file\nlet configuration = CSV.Configuration(delimiter: \",\", encoding: .utf8)\n\nlet parser = CSV.Parser(inputStream: stream, configuration: configuration)\ntry parser.parse()\n```\n\nIf you don't know the delimiter and encoding of the data, you can automatically detect it.\n\n```swift\nlet url = ...\nguard let configuration = CSV.Configuration.detectConfigurationForContentsOfURL(url) else {\n\treturn\n}\n```\n\n### Example\n\nParsing this CSV file\n\n```\na,b\n1,\"ha \"\"ha\"\" ha\"\n3,4\n```\n\nwill result in the following delegate calls.\n\n```\nparserDidBeginDocument\nparser(_:didBeginLineAt:) 0\nparser(_:didReadFieldAt:value:) a\nparser(_:didReadFieldAt:value:) b\nparser(_:didEndLineAt:) 0\nparser(_:didBeginLineAt:) 1\nparser(_:didReadFieldAt:value:) 1\nparser(_:didReadFieldAt:value:) ha \"ha\" ha\nparser(_:didEndLineAt:) 1\nparser(_:didBeginLineAt:) 2\nparser(_:didReadFieldAt:value:) 3\nparser(_:didReadFieldAt:value:) 4\nparser(_:didEndLineAt:) 2\nparserDidEndDocument\n```\n\n## Writer\n\n```swift\nlet stream = OutputStream(...)\nlet configuration = CSV.Configuration(delimiter: \",\", encoding: .utf8)\n\nlet writer = CSV.Writer(outputStream: stream, configuration: configuration)\ntry writer.writeLine(of: [\"a\", \"b\", \"c\"])\ntry writer.writeLine(of: [\"1\", \"2\", \"3\"])\n```\n\nThe code above produces the following output.\n\n```\na,b,c\n1,2,3\n```\n\n# TODOs\n\n- [ ] Support comments in CSV file\n\n# Contact\n\nMatthias Hochgatterer\n\nGithub: [https://github.com/brutella/](https://github.com/brutella/)\n\nTwitter: [https://twitter.com/brutella](https://twitter.com/brutella)\n\n\n# License\n\nswift-csv is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrutella%2Fswift-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrutella%2Fswift-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrutella%2Fswift-csv/lists"}