Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ranguvar

macrumors 6502
Original poster
Sep 18, 2009
318
2
Hi,

I got a text file (~1.5 MB) that contains about 25,000 lines. Each line contains values of a location (name, latitude, longitude, etc...). In my app, the user will search for locations, and the app will have to look them up in the file.

I thought about using CoreData (because of SQLite's great performance) to create a persistent store, then search it each time the user searches for a location.
However, creating the whole managed object model etc. seems to be somewhat overkill for my quite trivial task.

Is there any simpler way to do this, or do I have to use CoreData?

Thanks!
- ranguvar
 
If you want efficient search then you are probably going to be looking at some sort of indexed database style option at some point. One potentially simple option would be to split the file into a number of smaller files with a known set of properties: say latitude ranges. This would enable you to open and search a smaller file. This is basically a crude index on that value.

Other than that you could write a script that loads the data into a SQLite database with one table and just use raw or thinly wrapped SQLite (FMDB seems popular) to search the table.

I would probably look at the second option having the script to generate the SQLite database running as a build phase in your project.
 
Other than that you could write a script that loads the data into a SQLite database with one table and just use raw or thinly wrapped SQLite (FMDB seems popular) to search the table.

I would probably look at the second option having the script to generate the SQLite database running as a build phase in your project.

How would that compare to using CoreData performance- and effortwise?
 
Those more successful than me say that it'll perform way better than CoreData. Effort wise? Not sure but I imagine similar.

Many thanks for the link! Definitely a good read. From what I understand, what I'm trying to perform (sifting through a large table) is a "database-y" task. I'm not having any object relations, nor am I doing any object modifications, so I really only got "dumb" data. Thus, I should probably go with FMDB (or the likes), not CoreData.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.