1
1
# SwiftCSV
2
2
3
- ![ Swift 5.0 ] ( https://img.shields.io/badge/Swift-5.0 -blue.svg?style=flat )
4
- [ ![ Platform support] ( https://img.shields.io/badge/platform-ios%20%7C%20osx%20%7C%20tvos%20%7C%20watchos-lightgrey.svg?style=flat-square )] ( https://github.com/swiftcsv/SwiftCSV/blob/master/LICENSE.md )
5
- [ ![ Build Status] ( https://img.shields.io/travis/swiftcsv/SwiftCSV/master.svg?style=flat-square )] ( https://travis-ci.org/swiftcsv/SwiftCSV )
3
+ ![ Swift 5.3 ] ( https://img.shields.io/badge/Swift-5.3 -blue.svg?style=flat )
4
+ [ ![ Platform support] ( https://img.shields.io/badge/platform-ios%20%7C%20osx%20%7C%20tvos%20%7C%20watchos-lightgrey.svg?style=flat-square )] ( https://github.com/swiftcsv/SwiftCSV/blob/master/LICENSE.md )
5
+ [ ![ Build Status] ( https://img.shields.io/travis/swiftcsv/SwiftCSV/master.svg?style=flat-square )] ( https://travis-ci.org/swiftcsv/SwiftCSV )
6
6
[ ![ Code coverage status] ( https://codecov.io/gh/swiftcsv/SwiftCSV/branch/master/graph/badge.svg )] ( https://codecov.io/gh/swiftcsv/SwiftCSV )
7
- [ ![ CocoaPods Compatible] ( https://img.shields.io/cocoapods/v/SwiftCSV.svg?style=flat-square )] ( https://cocoapods.org/pods/SwiftCSV )
7
+ [ ![ CocoaPods Compatible] ( https://img.shields.io/cocoapods/v/SwiftCSV.svg?style=flat-square )] ( https://cocoapods.org/pods/SwiftCSV )
8
8
[ ![ Carthage compatible] ( https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat )] ( https://github.com/Carthage/Carthage )
9
- [ ![ License MIT] ( https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square )] ( https://github.com/swiftcsv/SwiftCSV/blob/master/LICENSE.md )
9
+ [ ![ License MIT] ( https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square )] ( https://github.com/swiftcsv/SwiftCSV/blob/master/LICENSE.md )
10
10
[ ![ Reviewed by Hound] ( https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg?style=flat-square )] ( https://houndci.com )
11
11
12
12
31
31
32
32
// From a file inside the app bundle, with a custom delimiter, errors, and custom encoding
33
33
let resource: CSV? = try CSV (
34
- name : " users" ,
35
- extension : " tsv" ,
36
- bundle : .main ,
37
- delimiter : " \t " ,
34
+ name : " users" ,
35
+ extension : " tsv" ,
36
+ bundle : .main ,
37
+ delimiter : " \t " ,
38
38
encoding : .utf8 )
39
39
} catch parseError as CSVParseError {
40
40
// Catch errors from parsing invalid formed CSV
@@ -55,10 +55,10 @@ class CSV {
55
55
/// - parameter delimiter: Character used to separate row and header fields (default is ',')
56
56
/// - parameter loadColumns: Whether to populate the `columns` dictionary (default is `true`)
57
57
/// - throws: `CSVParseError` when parsing `string` fails.
58
- public init (string : String ,
59
- delimiter : Character = comma,
58
+ public init (string : String ,
59
+ delimiter : Character = comma,
60
60
loadColumns : Bool = true ) throws
61
-
61
+
62
62
/// Load a CSV file as a named resource from `bundle`.
63
63
///
64
64
/// - parameter name: Name of the file resource inside `bundle`.
@@ -70,11 +70,11 @@ class CSV {
70
70
/// - throws: `CSVParseError` when parsing the contents of the resource fails, or file loading errors.
71
71
/// - returns: `nil` if the resource could not be found
72
72
public convenience init? (
73
- name : String ,
74
- extension ext : String ? = nil ,
75
- bundle : Bundle = .main ,
76
- delimiter : Character = comma,
77
- encoding : String .Encoding = .utf8 ,
73
+ name : String ,
74
+ extension ext : String ? = nil ,
75
+ bundle : Bundle = .main ,
76
+ delimiter : Character = comma,
77
+ encoding : String .Encoding = .utf8 ,
78
78
loadColumns : Bool = true ) throws
79
79
80
80
/// Load a CSV file from `url`.
@@ -85,9 +85,9 @@ class CSV {
85
85
/// - parameter loadColumns: Whether to populate the columns dictionary (default is `true`)
86
86
/// - throws: `CSVParseError` when parsing the contents of `url` fails, or file loading errors.
87
87
public convenience init (
88
- url : URL,
89
- delimiter : Character = comma,
90
- encoding : String .Encoding = .utf8 ,
88
+ url : URL,
89
+ delimiter : Character = comma,
90
+ encoding : String .Encoding = .utf8 ,
91
91
loadColumns : Bool = true )
92
92
}
93
93
0 commit comments