Question

I need to create a big table to csv file and compress it.

I can create the csv file like this: Xcode - Create csv/spreadsheet file

It is possible compress it with GZIP?

Thanks for all.

Best regards.

Was it helpful?

Solution

I recommend you use SSZipArchive: https://github.com/soffes/ssziparchive

Then you can do:

NSString *content = @"1,2,3"
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"somefile.zip"];
SSZipArchive *zip = [[SSZipArchive alloc] initWithPath:path];
[zip open];
[zip writeData:[content dataUsingEncoding:NSUTF8StringEncoding] filename:@"data.csv"];
[zip close];

That will produce a zip file named "somefile.zip" in the temporary directory, containing one file inside named "data.csv"

OTHER TIPS

The easiest way is to probably not use a standard copy build phase to move the file into place, but instead use shell script build phase to copy the file and then compress it in place with gzip.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top