I am making an iPhone app which requires the current Stock Prices.
I am receiving the data in CSV format from a link given below.
http://finance.yahoo.com/d/quotes.csv?s=RHT+MSFT&f=sb2b3jk
Is it possible to convert the CSV format to NSData or NSString format? If yes, how can I do so?
What can be the other alternatives for this?
Don’t re-invent the wheel: CHCSVParser is a native CSV parser written in Objective-C. It properly handles quoted fields, escaped characters, etc. It has convenience methods (
+[NSArray arrayWithContentsOfCSVFile:...]) and chunks the file reading so as not to produce low memory warnings.Here’s (more or less) how you’d use it. That the CSV file is remote complicates things a little bit, but not much (you have to download the contents of the URL into a string, and then pass that string into the parser).
This logs:
It returns an
NSArrayofNSArraysofNSStrings.