80,000 개 이상의 행과 100 개의 열을 포함하는 CSV 파일이 있습니다. 가능한 가장 효율적인 방법으로 CSV 데이터로드/액세스를 처리하려고합니다. 현재 CSVParser는 NSArray에 데이터를로드하지만 매우 느리거나 느립니다. 이것은 모바일 장치에서 파싱/로딩을 처리하기를 희망하면서 문제가됩니다. 바로 아이폰입니다.큰 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