Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 18th, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Append to python dictionary
  2. "5",7.30124705657363,2,12,7.45176205440562
  3. "18",6.83169608190656,5,11,7.18118108407457
  4. "20",6.40446470770985,4,10,6.70549470337383
  5. "3",5.37498781178147,17,9,5.9902122724706
  6. "10",5.12954203598201,8,8,5.58108702947798
  7. "9",3.93496153596789,7,7,4.35751055597501
  8.        
  9. global oldPriceCompRankDict
  10. oldPriceCompRankDict = {}
  11.  
  12. def increaseQuantityByOne(self, fileLocation):
  13.     rows = csv.reader(open(fileLocation))
  14.     rows.next()
  15.     print "PricePercentaget" + "OldQuantityt" + "newQuantityt" + "oldCompScoret" + "newCompScore"
  16.     for row in rows:
  17.         newQuantity = float(row[2]) + 1.0
  18.         newCompetitiveScore = float(row[1]) + float(math.log(float(newQuantity), 100))
  19.         print row[1] + "t", str(row[2])+"t", str(newQuantity) + "t", str(row[4]) + "t", newCompetitiveScore
  20.         oldPriceCompRankDict[row[3]].append(row[4])
  21.        
  22. from collections import defaultdict
  23.  
  24. oldPriceCompRankDict = defaultdict(list)
  25.        
  26. oldPriceCompRankDict[row[3]].append(row[4])
  27.        
  28. oldPriceCompRankDict[row[3]] = row[4]