#!/usr/bin/python
import os
import string
import math
import re
import sys

print sys.argv[1]

with open(sys.argv[1]) as f:
    content = f.read().splitlines()
print content[0]     ###
print content[len(content)-1]    ###

print "len(content): " ,  len(content)
DATES = []
CLOSE = []
VOLUME = []
OPEN = []
HIGH = []
LOW = []


for i in range(1, len(content)): 
  #content1 = content[i-1].split(",")
  content1 = content[i-1].replace('"', '').split(",")
  DATES.append(content1[0])
  CLOSE.append(float(content1[1]))
  VOLUME.append(float(content1[2]))
  OPEN.append(float(content1[3]))
  HIGH.append(float(content1[4]))
  LOW.append(float(content1[5]))


print "DATES: ", DATES    
print "CLOSE: ", CLOSE
print "VOLUME: ", VOLUME
print "OPEN: ", OPEN
print "HIGH: ", HIGH
print "LOW: ", LOW

SUM_CLOSE = 0
len4a = len(CLOSE)
#print "len4a: ", len4a
#close_ = [1, 2, 3, 4, 5]
#print math.fsum(close_)/len(close_)  #
print "Minimum Close  : ", min(CLOSE)
print "Average Close  : ", math.fsum(CLOSE)/len(CLOSE)  
print "Max Close      : ", max(CLOSE)


print "Minimum Volume : ", min(VOLUME)
print "Average Volume : ", math.fsum(VOLUME)/len(VOLUME)  
print "Max Volume     : ", max(VOLUME)


print "Minimum Open   : ", min(OPEN)
print "Average Open   : ", math.fsum(OPEN)/len(OPEN)
print "Max Open       : ", max(OPEN)


print "Minimum High   : ", min(HIGH)
print "Average High   : ", math.fsum(HIGH)/len(HIGH)  
print "Max High       : ", max(HIGH)


print "Minimum Low    : ", min(LOW)
print "Average Low    : ", math.fsum(LOW)/len(LOW)  
print "Max Low        : ", max(LOW)



def plusminus(LIST2):
  PLUSMINUSRES = [ ]
  compareval = LIST2[0]
  for i in range(0, len(LIST2)-1):
#     print LIST2[i]
     if LIST2[i] > compareval:
       PLUSMINUSRES.append("+")
     elif LIST2[i] == compareval:
       PLUSMINUSRES.append("0")
     else:
       PLUSMINUSRES.append("-")
     compareval = LIST2[i]
  print PLUSMINUSRES  
  return PLUSMINUSRES   
#  print LIST2

def close_volume_compare(PM1, PM2):
  COMPARE_RES = [ ]
  for i in range(0, len(PM1)-1):
    if PM1[i] == PM2[i]:
       COMPARE_RES.append("0")
    else:
       COMPARE_RES.append("1")
  return COMPARE_RES  

LIST1 = [3, 4, 5, 6, 7, 3]
print LIST1
PM_CLOSE = plusminus(CLOSE)
PM_VOLUME = plusminus(VOLUME)
PM_COMPARE = close_volume_compare(PM_CLOSE, PM_VOLUME)

print "PM_CLOSE:   ", PM_CLOSE
print "PM_VOLUME:  ", PM_VOLUME
print "PM_COMPARE: ", PM_COMPARE
f.close()

