Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm glad you like it :)</p> <p>Basically, <code>CHCSVParser</code> <em>only</em> parses CSV files. You give it a path to a CSV file, and it'll give you back a whole bunch of <code>NSStrings</code>. What you do beyond that point is entirely up to you.</p> <p>So let's say you've included a CSV file in your iOS app called "Data.csv". Here's how you'd use <code>CHCSVParser</code> to parse it:</p> <pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"csv"]; NSError *error = nil; NSArray *rows = [NSArray arrayWithContentsOfCSVFile:path encoding:NSUTF8StringEncoding error:&amp;error]; if (rows == nil) { //something went wrong; log the error and exit NSLog(@"error parsing file: %@", error); return; } </code></pre> <p>At this point, <code>rows</code> is an array. Each element in <code>rows</code> is itself an array representing a single row in the CSV file. And each element of <em>that</em> array is an <code>NSString</code>.</p> <p>So let's say your CSV file looks like this:</p> <pre><code>Barringer,Arizona,United States,Earth "Chicxulub, Extinction Event Crater",,Mexico,Earth Tycho,,,Moon Lonar,Maharashtra,India,Earth </code></pre> <p>If you run it through the parser, you'll get back the equivalent of this:</p> <pre><code>[NSArray arrayWithObjects: [NSArray arrayWithObjects:@"Barringer",@"Arizona",@"United States",@"Earth",nil], [NSArray arrayWithObjects:@"Chicxulub, Extinction Event Crater",@"",@"Mexico",@"Earth",nil], [NSArray arrayWithObjects:@"Tycho",@"",@"",@"Moon",nil], [NSArray arrayWithObjects:@"Lonar",@"Maharashtra",@"India",@"Earth",nil], nil]; </code></pre> <p>What you do with it then is your business. The CSV parser doesn't know anything about <code>UITableView</code>, 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.</p> <p>Also, remember that by using <code>CHCSVParser</code>, you agree to abide <a href="https://github.com/davedelong/CHCSVParser/blob/master/LICENSE" rel="noreferrer">the terms under which it is made available</a>. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload