Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grouping and computing

Status
Not open for further replies.

CSR01

Programmer
Jan 3, 2005
2
0
0
GB
All,

I have the following information in a csv file

Starting Position = 300
Date,Symbol,Description,T_Qty,Position
02-Jan-04,A,4000
05-Jan-04,A,-600
06-Jan-04,A,-900

I have this data for 1000s of securities for the whole of last year. I have to compute the position for all the rows.
For the first day it would be T_Qty + Starting position and that row would become
02-Jan-04,A,4000,4300

For the subsequent rows, it would be T-Qty + previous Position
05-Jan-04,A,-600,5700
06-Jan-04,A,-900,4800

I have only one security listed above. I have thousnads of securities like this.

My idea is to group by securities, then add up quantities going through line by line. Anyone having better idea and suggest me how to do this?

Thanks
Rama
 
Are there so many that you can't put them in a double level hash as
%data{symbol}{date} = value.

Then you could iterate over the symbols, sort by the date and regenerate the data.

 
Thanks Cchub for your reply, there are around 120,000 rows. But, I created a single hash and computed the value. I am getting the date outside.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top