Question

How comes when i run this code, the data that gets downloaded seems to have cropped off some information from the first row?

NSURL *url = [NSURL URLWithString:@"http://ichart.finance.yahoo.com/table.csv?   s=GOOG&d=6&e=27&f=2012&g=d&a=6&b=25&c=2011&ignore=.csv"];
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
NSURLConnection *connection= [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection start];

The data then gets sorted here:

NSString *strData = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];
strData = [strData stringByReplacingOccurrencesOfString:@"Date,Open,High,Low,Close,Volume,Adj Close" withString:@""];
NSArray* arrUncleanDataLine = [strData componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
NSMutableArray *arrCleanDataLine = [[NSMutableArray alloc]init];
NSString *temp = [[NSString alloc]init];

The top line gets cropped off. Why is this? Is it because NSData can only hold a certain amount of data?

Was it helpful?

Solution

Because you yourself remove the first line "Date,Open,High,Low,Close,Volume,Adj Close" by this code:

strData = [strData stringByReplacingOccurrencesOfString:@"Date,Open,High,Low,Close,Volume,Adj Close" withString:@""];

So just comment this line.

OTHER TIPS

I have fixed it. When i was downloading the data it was not appending the old data and adding it to the new data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top