I am developing a simple app. I am using sqlite to save data into a table (locally, in app documents folder). I want to problematically export this table data in a csv file and
Here what i have done to generate csv for tabular data. Here i have done it for simple testing. but what you need to do is to generate 2d array in such manner to produce NSArray like one i have done in this sample.
Here first component in NSArray is one row for table , second component is for second row of table and likewise...
NSArray *array = [NSArray arrayWithObjects:@"NAME,NUMBER",@"\nbhargavi1,12345",@"\nHiral,23456",@"\nHarish,34567", nil];
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *filename=[NSString stringWithFormat:@"test.csv"];
NSString *filePathLib = [NSString stringWithFormat:@"%@",[docDir stringByAppendingPathComponent:filename]];
[[array componentsJoinedByString:@","] writeToFile:filePathLib atomically:YES encoding:NSUTF8StringEncoding error:NULL];
please implement this. May be this could help you out.
i have implement this in my project and it works for me very nicely