CSV 0.0.2

CSV 0.0.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2014 年 12 月

Unclaimed 维护。



CSV 0.0.2

  • Ryan Davies

将数据格式化为逗号分隔值是一个简单的任务,但这个库旨在使其更加简单。

行是表内部的组件,起复合作用。序列化器访问每一行,在访问过程中进行格式化。

行被添加到表中

CSVRow *header = [[CSVRow alloc] initWithValues:@[@"Name", @"Age", @"Country"]];
CSVRow *ryan = [[CSVRow alloc] initWithValues:@[@"Ryan Davies", @20, @"England"]];
CSVRow *john = [[CSVRow alloc] initWithValues:@[@"John Smith", @34, @"France"]];
CSVTable *table = [[CSVTable alloc] initWithRows:@[header, ryan, john]];

并且序列化

NSMutableString *output = [[NSMutableString alloc] init];
CSVSerializer *serializer = [[CSVExporter alloc] initWithOutput:output];
[exporter serialize:table];

使用可变字符串初始化序列化器,既可以将其公开进行测试,也允许在多次序列化或其它过程中使用相同的字符串。

上述示例的结果是输出

Name, Age, Country
Ryan Davies, 20, England
John Smith, 34, France

将其导入 Excel 或 Numbers 会得到格式正确的电子表格。

安装

使用 CocoaPods 通过将 pod 'CSV', '~> 0.0.1' 添加到您的项目 Podfile 中来安装 CSV。

许可证

Copyright (c) 2013 Ryan Davies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.