Re: Exporting and Importing CoreData
Re: Exporting and Importing CoreData
- Subject: Re: Exporting and Importing CoreData
- From: Flavio Donadio <email@hidden>
- Date: Thu, 24 Mar 2011 11:53:04 -0300
Siegfried,
I am late in this thread, but I don't understand why you need import/export. Is it just meant for backup purposes or is it a facility for the users to get data from other applications into yours (and out of it)?
If it is the second case, why not stick with "delimited text" or "CSV-style" files?
XML is not easy to edit for the average user, although it sure is human-readable. CSV, on the other hand, is pure text and can be imported by Excel, Numbers or any other spreadsheet app. Users could get data from others sources (HTML tables, SQL databases, spreadsheets, whatever...) into your app and out of it.
I do this a lot: select table contents in web page, copy and paste into Numbers. I can delete some unneeded rows and columns, export into CSV and then insert into a database, for example. PHPMyAdmin can generate and import CSV files.
When validating aCSV file for importing, if a line does not conform to a pre-defined format, you'll have to drop it. You can always show a dialog at the end of the process that says something like "Some lines could not be imported." and generate a report in a file for the user to see which lines were dropped.
If you go the XML route, I am almost sure you'll need a DTD for validation.
I hope it helps...
Cheers,
Flavio
On 23/03/2011, at 21:55, Siegfried wrote:
> Hello,
>
> I need to create an export / import system for my app, and just thought that asking the list for some advices could help a lot.
>
> The CoreData database I have is fairly simple. No relationships, only 3 entities with no more than 4 properties each: numbers and strings. So I think exporting this as XML is the more appropriate solution. Also, it would allow users make changes in the file easily.
>
> Are there any serious drawbacks from using this method? Or may a better solution? What worries me most is the XML validation. It's not a high priority, but having an at least decent XML is worthwhile. The big question: A header saying XML version 1.0 is enough? Or do I need to create a DTD?
>
> Also, now on the mechanics, I think creating a mutable string and go appending parts of the XML in a loop is adequate for this task, and using NSXMLParser to parse it back should work. Indeed, the file will not be that big (usually a few hundreds of KBs, really extremes cases are 1 or 2MB). Well, at least I'm not aware of a framework to export / import CoreData, I don't even think it is possible.
>
> Any "yes" or "no" on my ideas are really appreciated.
>
> Thanks,
>
> Best wishes,
>
> Siegfried
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden