views:

96

answers:

1

Hello,

I need to make a cvs file in cocoa. To see how to set it up I created one in Numbers and opened it with text edit it looked like this:

Results,,,,,,,,,,,,
,,,,,,,,,,,,
A,10,,,,,,,,,,,
B,10,,,,,,,,,,,
C,10,,,,,,,,,,,
D,10,,,,,,,,,,,
E,10,,,,,,,,,,,

So to replicate this in cocoa I used:

NSString *CVSData = [NSString stringWithFormat:@"Results\n,,,,,,,,,,,,\nA,%@,,,,,,,,,,,\nB,%@,,,,,,,,,,,\nC,%@,,,,,,,,,,,\nD,%@,,,,,,,,,,,\nE,%@,,,,,,,,,,,",[dataA stringValue], [dataB stringValue], [dataC stringValue], [dataD stringValue], [dataE stringValue]]; 

Then

[CVSData writeToFile:[savePanel filename] atomically:YES];

But when I try to open the saved file with Numbers I get the error “Untitled.cvs” could not be handled because Numbers cannot open files in the “Numbers Document” format. Could this be something with the way cocoa is encoding the file?

Thanks for any help

+2  A: 

Use CSV (Comma Separated Value) instead of CVS (Concurrent Versioning System) in your file name.

Pablo Santa Cruz
Oh wow that was a stupid mistake can't believe I didn't see that. Thanks for seeing my obvious mistake. :)
happyCoding25