1
Reply

LINQ querying question

M

M

Nov 13 2008 11:02 AM
3k
I am new to LINQ...I'm not sure if what I want to do can be done within a query, but maybe one of you LINQ experts can tell if so, and if it can, hopefully show me how.  Here's the situation:

I have 3 files, whose names I have stored in a string[]:
string[] files2use = new string[] {"X","Y","Z"};

Each file represents a stock and contains the historical closing prices for that stock using the following format in each line:  11/11/2008,25.25 
(Each of the three files contains data for the same time period.)

What I would like to do is for a certain time period, (eg 1/1/2008 - 6/1/2008), create another daily series of values that represents how many of the three stocks closed at a higher price than 2 weeks ago.

So, for example, if on 6/1/2008 stock X's closing price was higher than its closing price 2 weeks prior and the same was true for stock Y and stock Z, then I would record a 3 for 6/1/2008.  If only stocks Y and Z had been higher, then I would have recorded a 2....and so on.

I've seen discussions of querying .csv files as well as joining that data with a different datasource...so I was thinking that maybe it be possible to do everything in one LINQ query.

OR is the proper approach to use LINQ only to join all of the data together from the 3 files and then afterwards step through it with two indexes....one at the current value and one at the two weeks ago value?

Answers (1)