I'm implementing CHCSVParser into my iPhone app (thanks Dave!) however I'm really confused on how to use it. I've read the read-me and searched some questions on SO but still not 100% sure what to do.
I have a .CSV file with maybe 5000 rows of data and 3-4 columns.
I want this data to in return, load my UITableView along with its corresponding detailViewController.
So I'm assuming I need to somehow implement the API's array method but can anyone help get me started?
I'm glad you like it :)
Basically,
CHCSVParser
only parses CSV files. You give it a path to a CSV file, and it'll give you back a whole bunch ofNSStrings
. What you do beyond that point is entirely up to you.So let's say you've included a CSV file in your iOS app called "Data.csv". Here's how you'd use
CHCSVParser
to parse it:At this point,
rows
is an array. Each element inrows
is itself an array representing a single row in the CSV file. And each element of that array is anNSString
.So let's say your CSV file looks like this:
If you run it through the parser, you'll get back the equivalent of this:
What you do with it then is your business. The CSV parser doesn't know anything about
UITableView
, so you get to take this data and re-structure it in a way that you're comfortable dealing with and that fits in to your data model.Also, remember that by using
CHCSVParser
, you agree to abide the terms under which it is made available. :)