Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>-[NSURL path]</code> is not doing what you're expecting.</p> <p>If I have the URL <code>http://stackoverflow.com/questions/4636428</code>, then it's <code>-path</code> is <code>/questions/4636428</code>. When you pass that path to CHCSVParser, it's going to try and open that path on the local system. Since that file doesn't exist, you won't be able to open it.</p> <p>What you need to do (as Walter points out) is download the CSV file locally, and then open it. You can download the file in several different ways (<code>+[NSString stringWithContentsOfURL:...]</code>, <code>NSURLConnection</code>, etc). Once you've got either the file saved locally to disk or the string of CSV in memory, you can then pass it to the parser.</p> <p>If this is a very big file, then you'll want to <code>alloc</code>/<code>init</code> a <code>CHCSVParser</code> with the path to the local copy of the CSV file. The parser will then read through it bit by bit and tell you what it finds via the delegate callbacks.</p> <p>If the CSV file isn't very big, then you can do:</p> <pre><code>NSString * csv = ...; //the NSString containing the contents of the CSV file NSArray * rows = [csv CSVComponents]; </code></pre> <p>That will return an <code>NSArray</code> of <code>NSArrays</code> of <code>NSStrings</code>.</p> <p>Similar to this last approach is using the <code>NSArray</code> category method:</p> <pre><code>NSString * csv = ...; NSError * error = nil; NSArray * rows = [NSArray arrayWithContentsOfCSVString:csv encoding:[csv fastestEncoding] error:&amp;error]; </code></pre> <p>This will return the same structure (an <code>NSArray</code> of <code>NSArrays</code> of <code>NSStrings</code>), but it will also provide you with an <code>NSError</code> object if it encounters a syntax error in the CSV file (ie, malformed CSV).</p>
    singulars
    1. This table or related slice is empty.
    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