Saving CSV in cocoa
- by happyCoding25
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