0

I am using CHCSVParser to convert sqlite file to csv format. At this link - How to export SQLite file into CSV file in iPhone SDK the example gives a precise way to to do it using FMDB library (wrapper over sqlite db). I am able to do it using FMDB. But I actually want to use CHCSV parser using core data (to access sqlite db).

Briefly my iOS app is trying to access sqlite db (earlier generated using core data) using core data and then convert to csv file. I am new to core data so finding it little difficult. Any help is appreciated.

Community
  • 1
  • 1
user1140780
  • 988
  • 2
  • 13
  • 29
  • Why don't you use the sqlite manager on firefox (or any console tool) to convert your data to CSV and then insert them to your app? Are the initial data always shipped as sqlite? – Panagiotis Jun 01 '12 at 08:55
  • I would like to convert it dynamically as sqlite db is generated as per user input in iOS app. That generated db is then have to be converted to csv. There is no initial data. – user1140780 Jun 01 '12 at 14:10
  • So why not converting the data directly to CSV? – Panagiotis Jun 01 '12 at 14:21
  • Data is in Sqlite db which is generated by app on run time when user presses submit button in app. I am not sure what do you mean by converting data directly as I do not have any prior data. – user1140780 Jun 01 '12 at 14:46
  • I assume that your code goes like this-- the user presses the submit button, and an sqlite file is generated (or cloned?) and the data are inserted. But CSV is much more simpler. The logic could be: button submit, collect data, encapsulate them in quotes (if char) and concatenate them in a comma for each row == 1 csv file. Do you require editing those files later? – Panagiotis Jun 01 '12 at 18:59

1 Answers1

0

You can not use Core Data to read an arbitrary SQLite file. Core Data normally uses SQLite to persist data, but Core Data takes control of how tables and columns in the database are named (and some other things, too). If you need to / want to read an SQLite file that wasn't written by Core Data, you need to read it with SQLite directly (or a wrapper like FMDB).

Daniel Eggert
  • 6,665
  • 2
  • 25
  • 41