simple aggregate task

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting simple aggregate task
# 1  
Old 06-17-2011
simple aggregate task

Hi experts,

I need an help on the task below.

INPUT: values separated by the tab,first row is the header
20110609    AS    A    300.5000
20110609    AS    R    200.5000
20110609    BR    A    111.5000
20110609    BR    R    222.5000
20110610    AS    A    100.5500
20110610    AS    R    150.5500
20110610    BR    A    199.5000
20110610    BR    R    288.5000
20110611    AS    A     50.0000
20110611    AS    R     50.0000
20110611    BR    A     98.0000
20110611    BR    R     97.0000
20110612    AS    A     90.0000
20110612    AS    R     80.0000
20110612    CO    A     12.0000
20110612    CO    R     13.0000
20110612    DE    A     112.0000
20110612    DE    R     113.0000
20110613    DE    A   38012.6920
20110613    DE    A   38012.6920

I need to calculate a three day AVERAGE PRICE for each day where the SIDE and the MARKET are the same (three day is just example - it should be CUSTOMIZABLE) :
For date 20110612 and side A and market AS - we will sum prices for (0612 +0611+0610) on the A side on the AS market,
so the summary will be (90+50+100,55 = 240,55)=SUM_SIDE_A then calculate the average which is SUM_SIDE_A/3 = 80,1833
for R side it will be (80+50+150,55=280,55=SUM_SIDE_R)/3 = 93.51
etc. for each day/market/side.
For days 20110609 or 20110610 when there is no record 3 days past, we will simple use the all existing records before.
Example : 20110609 : A side, market AS -> 300.5/ 1 =300.5 , 20110610 : 401.05/2 =200.525

OUTPUT should look like this: tab separated values, instead of 'xxx' should be similar summaries for other markets.
output should be sorted by date ascending , market alphabetically
20110609       AS          300.5000         200.5000
20110609       BR          xxx              xxx 
20110610       AS          200.525          175.525
20110610       BR          xxx              xxx 
20110611       AS          150.3500         133.6833
20110611       BR          xxx              xxx 
20110612       AS          80.1330          93.5156
20110612       BR          xxx              xxx 
20110612       CO          xxx              xxx 
20110612       DE          xxx              xxx 
20110613       AS          xxx              xxx
20110613       DE          xxx              xxx

In my real input there are of course hundreds of date and dozen of markets.
Thanks a lot for all replies

Last edited by hernand; 06-17-2011 at 06:13 AM..
# 2  
Old 06-17-2011
If it's simple why you don't write this program by yourself? Your previous posts are really interesting...
# 3  
Old 06-17-2011
Thanks Yazu for your HELP, I guess it should be simple for EXPERT, for which I don't consider myself.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Aggregate data within the file

Guys, I need to roll up data within the file and build a new file with the output and the same format as the original file. The data should be rolled up for each unique combination of ord,line,date and hour.. The last column appr is always " " Below is the format Original File: ... (8 Replies)
Discussion started by: venky338
8 Replies

2. Solaris

IPMP over aggregate in Solaris 11

hi all, i start with solaris 11 and i am disapointed by the change on ip managing. i want to set a ipmp over tow aggregate but i dont find any doc and i am lost with the new commande switch1 net0 aggregate1 | net1 aggregate1 |-----| |... (1 Reply)
Discussion started by: sylvain
1 Replies

3. Shell Programming and Scripting

Can Anyone help do my task in simple way..

Hi... I am trying extract data using 2 files.. 1. Data file - DATA.TXT containing data to be extracted 2. Column file - LIST.TXT header column to be extracted output not coming properly.. if the header field name matches with data file header extract data...this actually I wanted ... ... (7 Replies)
Discussion started by: nex_asp
7 Replies

4. Shell Programming and Scripting

need a script that does a simple task on multiple unix servers.

hi guys, i need a script that does a simple task on multiple aix servers. if possible with both telnet and ssh. the simple task i wanna do is connect to a server and run "ifconfig -a" and get the output. nextweek i need to do similar jobs on like 50 servers... :( can anybody help me with making... (2 Replies)
Discussion started by: curtis911
2 Replies

5. Shell Programming and Scripting

Simple renaming task?

Hi guys, could someone tell me how i could create a label like this: mybox01, mybox04, mybox12, mybox10 when i have the values "mybox1", "mybox4","mybox12","mybox10" as a prefix and a number. If the number is below 10 then add a zero before the number? A one liner? A long approach is to... (2 Replies)
Discussion started by: muay_tb
2 Replies

6. IP Networking

Aggregate two internet connections

Hi I have a question related to load balancing.I have two separate internet connections with 2Mbps speed and i would like to aggregate this two connections intro one connection with 4Mbps.Is it possible to do that, to put a Linux or Unix machine as a gateway?I read some stuff to split the... (3 Replies)
Discussion started by: tafil
3 Replies

7. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

8. UNIX for Advanced & Expert Users

AWK aggregate records

Hy all, I have a problem...can some one help me... I have a file of records sort: 30|239|ORD|447702936929 | |20080728|141304|00000900|2|0000000000000536|28181|0000000006|0000000001|10|1 30|239|ORD|447702936929 | ... (4 Replies)
Discussion started by: anaconga
4 Replies

9. UNIX Desktop Questions & Answers

Aggregate title to an archive.log

Hello how are you, i have a question i have a file ale.log and i want to agregate a title and later a space when the text is over and put another title (when the text is over) how can i do this? thank you Example Last ------>(Title) i want to agregate pupu pupu pupu pupu... (1 Reply)
Discussion started by: enkei17
1 Replies

10. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 Replies
Login or Register to Ask a Question