#!/usr/bin/env python
#
# This script takes a single input file describing job information.
# It writes, as ouput to stdout, aggregate counts of jobs by area.

# input file format has 5 columns
#  Column  0: degree class
#  Column  1: job title
#  Column  2: job code
#  Column  3: 2008 count
#  Column  4: 2018 projection
#  Column  5: Expected addition, next decade

import math
import sys
import os
import re

if (len(sys.argv) != 2):
  print "usage:", sys.argv[0], "input"
  sys.exit(-1)


inputName = sys.argv[1]
if (not (inputName[len(inputName) - 4:] == ".txt")):
    print "Input " + inputName + " does not end with .txt, aborting."
    sys.exit(-1)
    
if (not os.path.exists(inputName)):
    print "File " + inputName +  " does not exist, aborting."
    sys.exit(-2)

inputFile = open(inputName, 'r')

rows = []
for line in inputFile:
    line.rstrip()
    words = re.split("\t+", line)
    datum = ()
    if (len(words) == 0):
      continue
    elif (len(words) != 6):
      print "input error:", words
      print "  - expecting 6 tokens"
      sys.exit(-1)
    else:
      datum = (words[0], words[3], words[5])
    rows.append(datum)

bio = 0
cs = 0
eng = 0
phy = 0

for datum in rows:
  degree = datum[0]
  current = int(datum[1])
  growth = int(datum[2])

  val = growth + current/4
  
  if (degree == 'Bio'):
    bio = bio + val
  if (degree == 'CS'):
    cs = cs + val
  if (degree == 'Eng'):
    eng = eng + val
  if (degree == 'Phy'):
    phy = phy + val
    
print "Bio", bio/10
print "CS", cs/10
print "Eng", eng/10
print "Phy", phy/10



 
