Note that there are some explanatory texts on larger screens.

plurals
  1. POPerformance Issues when loading big CSV file (Objective-C)
    primarykey
    data
    text
    <p>I have a CSV file that contains over 80,000 rows and 100 columns. I'm trying to handle loading /accessing the CSV data in the most performance-efficient way possible. Right now my CSVParser loads the data into an NSArray, but it's extremely slow/sluggish; this is a problem as I hope to handle this parsing/loading on a mobile device: the iPhone.</p> <p>Any suggestions for an alternate method would be much appreciated. Thank you</p> <p>UPDATE:</p> <p>For future reference/discussion, I now have the following attempt: </p> <pre><code>// 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]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload