2012-03-02 12 views
0

サーバ上にあるCSVファイルからデータを読み込もうとしています。このファイルには大量のデータがあります。下に示すように、現在、私はNSURLREQUESTを使用してこのファイルを読んでいる:「*:キャッチされない例外により「NSRangeException」、理由にアプリを終了:私はこのファイルを読み込むしようとしたとき、私はこのエラーで終わった サーバ上のcsvファイルからコアデータにデータをインポートする

-(void)serverConnect{ NSMutableURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://spider90.dyndns.org:8080/sid/test.csv"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0]; NSURLConnection *connection= [[NSURLConnection alloc] initWithRequest:request delegate:self]; } -(void)connection :(NSURLConnection *) connection didReceiveData:(NSData *)data{ response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSString *stripped1 = [response stringByReplacingOccurrencesOfString:@"\r" withString:@""]; NSMutableArray *rows = [NSMutableArray arrayWithArray:[stripped1 componentsSeparatedByString:@"\n"]]; NSMutableArray *contentArray = [NSMutableArray array]; NSMutableArray *contentArray1 = [NSMutableArray array]; NSArray *components; NSString *startpoint; for (int i=0;i<[rows count]; i++) { if(i == 0 || [[rows objectAtIndex:i] isEqualToString:@""]){ continue; } components = [[rows objectAtIndex:i] componentsSeparatedByString:@","]; if(i == 1){ startpoint = [components objectAtIndex:0]; NSLog(@"startpoint:%@",startpoint); } id x = [components objectAtIndex:0] ; id y = [components objectAtIndex:1]; id z = [components objectAtIndex:2]; [contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x,@"X",y,@"Y", nil]]; [contentArray1 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x,@"X",z,@"Y", nil]]; NSLog(@"Contents of Uterus Contraction: %@",contentArray); NSLog(@"Contents of Heart Beat: %@",contentArray1); } [_graphHostingView setContentSize:CGSizeMake(2000, 1000)]; _graphHostingView.scrollEnabled = YES; _graphHostingView.showsHorizontalScrollIndicator = YES; _graphHostingView.showsVerticalScrollIndicator = YES; _graphHostingView.userInteractionEnabled = YES; self.scatterPlot = [[TUTSimpleScatterPlot alloc] initWithHostingView:_graphHostingView andData:contentArray andString:startpoint]; self.scatterPlot1 = [[TUTSimpleScatterPlot alloc] initWithHostingView:_graphHostingView andData:contentArray1 andString:startpoint]; [self.scatterPlot plot1]; [self.scatterPlot1 plot2]; } 

- [NSMutableArray objectAtIndex:]:境界1を超えたインデックス1。[0 .. 0] '。

コアデータを使用してファイルからデータを保存しようとしました。問題はファイルにあります。ライブで更新されているので、ファイルからデータベースに追加した以前の値に戻す必要があります。私が探しているものに私を導くための提案はありますか?データ範囲は約21K +データ行です。 http://imgur.com/UluaC - データのスクリーンショットを示します。

答えて

0

私はコメントする評点が足りませんが、1行または複数の行が空白だと推測しています。コンポーネントはNSArrayではありませんが、NSMutableArrayではなくファイルの空白行が原因です。

関連する問題