tones1986 0 Junior Poster

Hey Folks. I have to write a script that will basically take input from 3 different files which contain the following:

product (file contains the following - FS=".")
-product ID (Int number)
-description (alphanumeric text)
-price (floating pt. number, with 2 sig. digits)

sales (file contains the following - FS=",")
-product ID (Int number)
- quantity (int number)
- date (in form DD:MM:YYYY)
- associate ID (int number)

associates (file contains the following - FS="/")_
- associate ID (int number)
- name (alphanumeric text)
- salary (int number)
- Position (aplhanumeric text)

I have to basically take these 3 files and use any method (would like to use awk, arrays, - the very basics if possible, not expert stuff, minmal the better - the better ill understand it).
I need to compute the saleas amount per associate for the year 2007 (not all dates are in 2007, some are 2006) and print them out listed ranked on sales totals.

I have an idea of how i would like to it by studying some notes.

Would something like this work?

salesInfo=()
awk -F/ '{salesInfo [$4] += $ }' sales

Sales file is:

110,1,01:02:2007,22
110,2,02:02:2007,23
109,1,03:03:2006,24
104,2,03:02:2007,24
104,3,03:02:2007,24
113,92,12:02:2007,24
.... about 20 more entries
product ID, quantity, date, empoyee ID (form of data)

How can i add up the associates total of sales per each item. For examle, associate 24 above sold items 109, 104 and 113...but sold 104 to two different customers (2 items to one, 3 to the other customer)... how can you add such a thing up? The above effort should be along the right lines, but how could i set it to do multiple...

Hope this is easy to understand for someone out there. Any ideas would be awesome. I just need a kick up the rear and ill get this working. Thanks folks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.