
Untitled
By: a guest on
Jul 18th, 2012 | syntax:
None | size: 1.01 KB | hits: 12 | expires: Never
Append to python dictionary
"5",7.30124705657363,2,12,7.45176205440562
"18",6.83169608190656,5,11,7.18118108407457
"20",6.40446470770985,4,10,6.70549470337383
"3",5.37498781178147,17,9,5.9902122724706
"10",5.12954203598201,8,8,5.58108702947798
"9",3.93496153596789,7,7,4.35751055597501
global oldPriceCompRankDict
oldPriceCompRankDict = {}
def increaseQuantityByOne(self, fileLocation):
rows = csv.reader(open(fileLocation))
rows.next()
print "PricePercentaget" + "OldQuantityt" + "newQuantityt" + "oldCompScoret" + "newCompScore"
for row in rows:
newQuantity = float(row[2]) + 1.0
newCompetitiveScore = float(row[1]) + float(math.log(float(newQuantity), 100))
print row[1] + "t", str(row[2])+"t", str(newQuantity) + "t", str(row[4]) + "t", newCompetitiveScore
oldPriceCompRankDict[row[3]].append(row[4])
from collections import defaultdict
oldPriceCompRankDict = defaultdict(list)
oldPriceCompRankDict[row[3]].append(row[4])
oldPriceCompRankDict[row[3]] = row[4]