Need help reading a csv to NSString and then to NSMutableArray. I need to output the name of a certain row base on car.
file ex:
car, bike, wheels
toyota, mountainbike, rims
..
..
..
Need help reading a csv to NSString and then to NSMutableArray. I need to output the name of a certain row base on car.
file ex:
car, bike, wheels
toyota, mountainbike, rims
..
..
..
[NSString stringWithContentsOfFile: encoding: error] will read your csv file.
Once you have your file into a NSString you can use componentsSeparatedByString: to split it as you need. For example, to split it into an array based on line feeds:
NSArray *lines = [csvString componentsSeparatedByString:@"\r\n"];
Hope that helps.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.