开发者

Can't write CSV file using CHCSVParser (CHCSVWriter)

开发者 https://www.devze.com 2023-03-19 20:20 出处:网络
I want to export data from my application into a csv file. I found CHCSVParser by Dave Delong https://github.com/davedelong/CHCSVParser

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

精彩评论

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