ios read csv file at project directory -
i have implemented module reading csv file
the project construction follows:
project --test_de.csv --folder --controller.h --controller.m but result shows no response. no words added:
2014-06-19 15:32:16.817 marker[1748:60b] /var/mobile/applications/e2b95450-429d-4777-97be-0209522efdef/documents/test_de.csv 2014-06-19 15:32:16.824 marker[1748:60b] ( ) the below code
nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring* fullpath = [paths objectatindex:0]; fullpath = [fullpath stringbyappendingpathcomponent:@"test_de.csv"]; nslog(@"%@", fullpath); nsmutablearray *titlearray=[[nsmutablearray alloc]init]; nsstring *filedatastring=[nsstring stringwithcontentsoffile:fullpath encoding:nsutf8stringencoding error:nil]; nsarray *linesarray=[filedatastring componentsseparatedbystring:@"\n"]; int k=0; (id string in linesarray) if(k<[linesarray count]-1){ nsstring *linestring=[linesarray objectatindex:k]; nslog(@"%@",linestring); nsarray *columnarray=[linestring componentsseparatedbystring:@"\n"]; [titlearray addobject:[columnarray objectatindex:0]]; k++; } nslog(@"%@",titlearray);
according soulwithmobiletechnology how it
[self readtitlefromcsv:csvpath atcolumn:0]; and our method looks following:
-(void)readtitlefromcsv:(nsstring*)path atcolumn:(int)column { titlearray=[[nsmutablearray alloc]init]; nsstring *filedatastring=[nsstring stringwithcontentsoffile:path encoding:nsutf8stringencoding error:nil]; nsarray *linesarray=[filedatastring componentsseparatedbystring:@"\n"]; int k=0; (id string in linesarray) if(k<[linesarray count]-1){ nsstring *linestring=[linesarray objectatindex:k]; nsarray *columnarray=[linestring componentsseparatedbystring:@";"]; [titlearray addobject:[columnarray objectatindex:column]]; k++; } nslog(@"%@",titlearray); } ios csv
No comments:
Post a Comment