Go to file
Yasuhiro Hatta d951999a89 Update podspec 2016-06-11 17:49:19 +09:00
CSV.xcodeproj Add tvOS target for Carthage 2016-06-11 13:47:48 +09:00
Sources Update project 2016-06-11 13:33:00 +09:00
Tests Update project 2016-06-11 13:33:00 +09:00
.gitignore Initial commit 2016-06-11 02:10:59 +09:00
.travis.yml Fix CI setting 2016-06-11 14:00:29 +09:00
CSV.swift.podspec Update podspec 2016-06-11 17:49:19 +09:00
LICENSE Initial commit 2016-06-11 02:10:59 +09:00
Package.swift Add Package.swift 2016-06-11 12:08:43 +09:00
README.md Update README.md 2016-06-11 17:48:15 +09:00

README.md

CSV.swift

CSV reading library written in Swift.

Usage

From CSV string

import CSV

let csvString = "1,\"foo\"\n2,\"bar\""
for row in try! CSV(string: csvString) {
    print("\(row)")
    // => ["1", "foo"]
    // => ["2", "bar"]
}

From file path

import CSV

for row in try! CSV(path: "/path/to/file.csv") {
    print("\(row)")
}

Getting the header row

let csv = try! CSV(
    path: "/path/to/file.csv",
    hasHeaderRow: true) // default: false

let headerRow = csv.headerRow!

for row in csv {
    // ...
}

Provide the character encoding

If you use a file path, you can provide the character encoding to initializer.

let csv = try! CSV(
    path: "/path/to/file.csv",
    encoding: NSUTF8StringEncoding)

Installation

CocoaPods

pod 'CSV.swift', '~> 0.1'

Carthage

github "yaslab/CSV.swift" ~> 0.1

Swift Package Manager

import PackageDescription

let package = Package(
    name: "PackageName",
    dependencies: [
        .Package(url: "https://github.com/yaslab/CSV.swift", majorVersion: 0, minor: 1)
    ]
)

License

CSV.swift is released under the MIT license. See the LICENSE file for more info.