views:

47

answers:

1

Hi all,

Ive been struggling with this for a couple of days now and after scouring the internet I still havent got it working. I have a csv file, from which I need to populate an sqlite db to use with core data.

I thought I had found a solution here http://ablogontech.wordpress.com/2009/07/13/using-a-pre-populated-sqlite-database-with-core-data-on-iphone-os-3-0/ but I cannot for the life of me get it to work. Here are the steps I have taken.

  1. Created a new Core Data project and generated the model and Managed Object classes;
  2. Performed a fetch request in vdl of rootViewController (Im not sure why this is neccessary but apparantly it is?)
  3. Copied the xxx.sqlite from the documents directory of my app into another directory.
  4. Executed the following sqlite commands from the terminal:

sqlite3 xxx sqlite> .mode csv yyy sqlite> .import yyy.csv yyy

Now when it comes to importing the csv data into my table I get a no such table error! Also when i execute a .tables command I get Z before my table name? I have imported data from a csv into a table this way before but not using a core data generated db and I think this is where the problem lies. Does anyone know where Im going wrong or of a better solution to my problem. Please let me know as Im going crazy with this..

Many thanks

Jules

A: 

Take a look at this post What you want to do is set up your core data stack then import each record and insert new managed objects and use the values from the csv to set your object's properties.

falconcreek
Hi, thanks for the reply. I have actually decided on using a similaer method to this which I found here.http://iphoneinaction.manning.com/iphone_in_action/2009/09/core-data-part-5-prefilling-data.htmlMany thanks again
Jules