Newer
Older
#!/usr/bin/python
import csv
def get_data(filename):
'''function to read the data form the input csv file to use in the analysis'''
reader = [] # Just in case the file open fails
with open(filename, 'rb') as f:
reader = csv.reader(f,delimiter=',')
#returns all the data from the csv file in list form
#f.close() # May need to close the file when done
return list(reader) # only return the reader when you have finished.
your_list = []
your_list += get_data('modules-anselm.csv')
your_list += get_data('modules-salomon.csv')
#print your_list
a=[["python/2.8.1",1],["python/2.9.1",2],["python/2.8.1",4],["python/3.0.1",4]]
counts = dict()
for i in your_list:
#print i[0]
#print int(i[1])
counts[i[0]]=counts.get(i[0], 0) + int(i[1])
c=[
"---",
"--A",
"-S-",
"-SA",
"U--",
"U-A",
"US-",
"USA",
]
print "| Module | Versions | Clusters |"
print "| ------ | -------- | -------- |"
software = dict()
versions = ''
clusters = ''
prev = ''
split = m.split('/')
if len(split) > 1:
a = split[0]
b = split[1]
if split[0] <> prev:
software[a] = {}
software[a][b] = c[i]
prev = a
#print software.items()
for m in sorted(software.items()):
software = m[0]
versions = ''
clusters = ''
#print '</br>'.join(m[1].keys())
#print '</br>'.join(m[1].values())
print "| %s | %s | %s |" % (software, '</br>'.join(m[1].keys()), '</br>'.join(m[1].values()))