私は80,000行以上100列を含むCSVファイルを持っています。私は可能な限り最も効率的な方法でCSVデータのロード/アクセスを処理しようとしています。現在、CSVParserはデータをNSArrayにロードしますが、非常に遅い/遅いです。これは、私がモバイルデバイス上でこの解析/ロードを処理することを望んでいるとして、問題です:iPhone。大きなCSVファイル(Objective-C)を読み込む際のパフォーマンスの問題
代替方法の提案は大変ありがたいです。ありがとう
UPDATE:将来の参照/議論、私が今持っている次の試みのために
:私はあなたが「別の方法」によって何を意味するかわからないんだけど
// Mark time the parser starts
NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
// Parse the CSV file
[parser parse];
NSTimeInterval end = [NSDate timeIntervalSinceReferenceDate];
// Print how long the parsing took
NSLog(@"raw difference: %f", (end-start));
// Copy the allLines array from the parsing delegate
NSArray *allOfTheRows = [NSArray arrayWithArray:d.allLines];
NSLog(@"There are %i lines in the csv file", [allOfTheRows count]);
NSFileManager *f = [[NSFileManager alloc] init];
NSString *filePath = @"/Users/..../rawData"; // This is of course not a literal location...
// Archive the array as NSData
NSData *someData = [NSKeyedArchiver archivedDataWithRootObject:allOfTheRows];
// Write the data to a file
[f createFileAtPath:filePath contents:someData attributes:nil];
/*
If I were to load the data from the iPhone, i'd copy the newly created someData file above to my application's mainBundle, and then unarchive the NSData to an array on the iPhone
*/
// Read the data back as an array
NSData *readData = [NSData dataWithContentsOfFile:filePath];
NSArray *bigCollectionReadBack = [NSKeyedUnarchiver unarchiveObjectWithData:readData];
私はデータをどのように使用しているのか、またデータが良い代替アプローチを示唆することができるかどうかにかかっていると思います。最高のオプションではないかもしれないようなCSVの音(オプションがある場合) – Danny