Import data from Excel File to Core Data - iphone

I have thousands of students records in Excel sheet. Now I will import that all data into Coradata [from Excel sheet to Coredata] and I will create my iPhone application using that coredata.
I don't have any idea, how to import Excel file data into coredata.

You're thinking to broadly. You need to decompose this problem further. Here's your real problem:
How do I read an Excel file into memory?
How do I create Core Data objects?
"Excel" has nothing to do with "Core Data". They are entirely disjoint topics.
For the first question, there are several options. You could try and find a library that reads .xls or .xlsx files directly, or you could require that the file be in a different format (like CSV or something).
For the second question, that's easily answered by reading the Core Data documentation.

I would convert the file to xml.
There are plenty of codes showing how to parse xml.

Related

Convert OpenStreetMap POI Data to CSV

I am looking to extract some Point of Interest (POI) data from OpenStreetMap in a tabular format. I have used this link navigated to the relevant country and downloaded the file,
http://download.geofabrik.de/
What I get is a file with the .osm.pbf extension. However, I think it is possible to download the files in other formats like .shp.zip and .osm.bz2. Is there some way that I can convert this data into a tabular format like a CSV file?
I came across a tool called Osmosis which can be used to manipulate data in these formats, but I am not sure if it can be used for this purpose,
https://wiki.openstreetmap.org/wiki/Osmosis
I was able to successfully install in on my Windows machine though.
To be frank, I am not even sure if this gives me what I want.
In essence, what I am looking for is Sri Lankan POI data that contains the following attributes,
https://data.humdata.org/dataset/hotosm_lka_points_of_interest
If the conversion of this file does not give me data in this format, then I am open to other approaches as well? What is the best way to go about acquiring this data?

Insert a PDF file into Core Data?

I'm using my app to import some PDF files.
But I'm trying to insert my PDF file int my database. I'm using Core Data. Is it possible to do this ? If it is, how can I do it ? Which kind of types I have to use (NSData, NSDocument, ... ?)
Thanks you so much! :)
To store a PDF (or really any big data blob):
Use the Core Data "binary" type for the attribute, which corresponds to NSData.
In your Core Data model, turn on "Allows External Storage" for the attribute so that Core Data can store the data outside of the persistent store.
It's often better to just write the PDF to a file, and store the filename in your persistent store instead of the whole file.
Usually for large files, i.e large images or pdf files, what you should save in core data is simply a reference to the file, and store the pdf in NSCachesDirectory or in a permanent directory, depending on your needs.
Hope that helps.

Import Excel Files into Powerbuilder

I would like to import an Excel .xls file workbook into Powerbuilder. The file has 2 sheets and these sheets must be imported into 2 differenct db tables.
Any assistance is kindly appreciated.
Thanks
John.
First thing, there's nothing automagic, along the lines of a one-line solution that you could get for other file formats. There's a manual method, there's a scripting approach, and you can probably merge the two as a third option.
For a manual method, you can go into Excel and export your data as something that will import into a DataWindow. You don't mention your PowerBuilder version, but the file format for importing from Excel that comes to mind is CSV, which was added in PB9.
For a scripting approach, you can use OLE (assuming Excel is installed on the client machine) and access data however you want with the scripting engine, moving it into PowerBuilder in whatever format you want.
To mix the methods, you could use OLE to export the file to a couple of CSVs, then dw.FileImport() the data in.
Good luck,
Terry.
Postscript: Sybase has examples of OLE access, and examples of using ODBC, a solution I had neglected before.
If you give names to the areas with the data in Excel and then setup ODBC connections that point to them, you can access them like a database table from within PowerBuilder.

Loading a CSV into Core Data managed sqlite db

I have a CSV file containing data.
I want to load it into a Core Data managed sqlite db.
I just ran one of the sample Core Data Xcode apps and noticed it created the db file.
I noticed table names all started with Z and the primary keys were stored in separate table so from this am I right in presuming that just importing the CSV data directly into the db using sqlite3 command line might mess up primary keys.
Do I need to write a program to read in the CSV line by line and then create objects for each row and persist them to the db.
Anyone got any code for this?
And can I write a desktop client to do this using Core Data. If so will the db be fine to use in IPhone core data app?
Can I then just include the prefilled db in my project and it will be deployed with the app correctly or is there something else I should do.
Use NSScanner to read your CSV file into the NSManagedObject instances in your Core Data store.
I have some categories on NSString for reading and writing CSV files from/to NSArrays. I'll post them online and edit my answer with a link to it.
edit
They're online here: http://github.com/davedelong/CHCSVParser

Export Core Data information to Excel Sheet

I want to have an iPhone app where the user can export the data held by the application to an Excel spreadsheet (as well as a host of other formats).
So the idea is that each entity would be a new row in the sheet, with the attributes being different columns.
Is this possible?
Excel and similar programs can import files that are in a delimited text format such as CSV.
It is definitely possible to manipulate Core Data attributes into strings and then combine them in such a format using the strategy that you describe: instances of an entity are rows and attributes are columns.
Note: you would need a different file for each entity that you wanted to export.
Do you need to do anything with the relationships between entities?
Did you have a specific concern?