Latest 4.0.0
Homepage https://github.com/GyazSquare/GSCSVSerialization
License MIT
Platforms ios 8.0, osx 10.6, tvos 9.0, watchos 2.0, requires ARC

Build Status

Important: This library is deprecated, it is recommended you look at GSLCSVSerialization.

GSCSVSerialization is an Objective-C CSV parser for iOS, OS X, watchOS and tvOS.

Requirements

  • Xcode 8.1 or later
  • Base SDK: iOS 10.1 / OS X 10.12 / watchOS 3.1 / tvOS 10.0 or later
  • Deployment Target: iOS 8.0 / OS X 10.6 / watchOS 2.0 / tvOS 9.0 or later

Installation

CocoaPods

Add the pod to your Podfile:

# ... snip ...

pod 'GSCSVSerialization'

Install the pod:

$ pod install

Source

Check out the source:

$ git clone https://github.com/GyazSquare/GSCSVSerialization.git

Usage

Creating a CSV Object

GSCSVSerialization can create a CSV object from a RFC 4180-compliant CSV data by using the following methods:

+ (nullable __kindof NSArray<__kindof NSArray<__kindof NSString *> *> *)CSVRecordsWithData:(NSData *)data encoding:(NSStringEncoding)encoding options:(GSCSVReadingOptions)opt error:(NSError **)error;
+ (nullable __kindof NSArray<__kindof NSArray<__kindof NSString *> *> *)CSVRecordsWithStream:(NSInputStream *)stream encoding:(NSStringEncoding)encoding options:(GSCSVReadingOptions)opt error:(NSError **)error;

For example, if you parse CSV data below,

aaa,bbb,ccc
zzz,yyy,xxx

you can get a CSV object like this:

@[
    @[@"aaa",@"bbb",@"ccc"],
    @[@"zzz",@"yyy",@"xxx"]
]

Creating CSV Data

GSCSVSerialization can create CSV data from a CSV object by using the following methods:

+ (nullable NSData *)dataWithCSVRecords:(NSArray<NSArray<NSString *> *> *)records encoding:(NSStringEncoding)encoding options:(GSCSVWritingOptions)opt error:(NSError **)error;
+ (NSInteger)writeCSVRecords:(NSArray<NSArray<NSString *> *> *)records toStream:(NSOutputStream *)stream encoding:(NSStringEncoding)encoding options:(GSCSVWritingOptions)opt error:(NSError **)error;

A records object is a two-dimensional array containing field strings. You should check whether the input will produce valid CSV data before calling these methods by using isValidCSVRecords:.

License

GSCSVSerialization is licensed under the MIT License.

See the LICENSE file for more info.

Latest podspec

{
    "name": "GSCSVSerialization",
    "version": "4.0.0",
    "authors": "GyazSquare",
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/GyazSquare/GSCSVSerialization",
    "source": {
        "git": "https://github.com/GyazSquare/GSCSVSerialization.git",
        "tag": "v4.0.0"
    },
    "summary": "An Objective-C CSV parser for iOS, OS X, watchOS and tvOS.",
    "platforms": {
        "ios": "8.0",
        "osx": "10.6",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "requires_arc": true,
    "source_files": "GSCSVSerialization/*.{h,m}",
    "deprecated_in_favor_of": "GSLCSVSerialization"
}

Pin It on Pinterest

Share This