开发者

Can't write CSV file using CHCSVParser (CHCSVWriter)

I want to export data from my application into a csv file.

I found CHCSVParser by Dave Delong

https://github.com/davedelong/CHCSVParser

I creat开发者_开发问答ed a test project, imported CHCSVWriter and wrote this:

CHCSVWriter * csvWriter = [[CHCSVWriter alloc] initWithCSVFile:@"~/testfile.csv" atomic:NO];
    [csvWriter writeField:[NSString stringWithFormat:@"One"]];
    [csvWriter writeLine];
    [csvWriter writeField:[NSString stringWithFormat:@"Two"]];
    [csvWriter writeLine];
    [csvWriter closeFile];
    [csvWriter release];

But I get no testfile.csv in the Finder :(

What am I doing wrong?


You will need to expand the ~ for this to work. You can either update the parser to handle the ~ for you or you can initialize the parser like this,

NSString * filePath = @"~/testfile.csv";
filePath = [filePath stringByExpandingTildeInPath];

CHCSVWriter * csvWriter = [[CHCSVWriter alloc] initWithCSVFile:filePath atomic:NO];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜