Olga Dalton
Olga Dalton

Reputation: 849

Parsing question

I would like to use cCSVParse http://michael.stapelberg.de/cCSVParse

in my project. I receive csv data from internet and want to parse it and save to core data. cCSVParse seems to be appropriate class of it. But it can only read csv data from file. When I receive data from internet, I wouldn't like to save it to file. Is there any way to use it for parsing data from NSData or NSString?

Upvotes: 0

Views: 257

Answers (1)

Hot Licks
Hot Licks

Reputation: 47749

One approach is to surround the CSV data (one row at a time) with [] chars and parse it with a JSON parser. (But note that this only works if the non-numeric data items are enclosed in quotes.)

Or you can simply use

NSArray* items = [csvRow componentsSeparatedByString:@","];

if the data items aren't enclosed in quotes.

Upvotes: 1

Related Questions