Bug in Automation

@KemiraGroup discovered a little bug in my automation code for tweet statistics. I tested with Firefox and Safari and it worked for me… but then Peter Sjöholm (@sjoholm) informed that the bug manifested itself in IE8 & XP. I reproduced using IE6 and XP and then fixed the bug.

The reason why bug happened was because of one little comma… The excerpt below shows the bug in the list that is used to generate bar chart with Google Charts.

['Thehomedepot',0],
        ]);

The code below has no comma and it works.

['Thehomedepot',0]
        ]);

The bug fix in the code generation is below.

LAST=len(rankingDict)-1
i=0
for company,tweetCount in rankingDict:
  if i==LAST:
    htmlFile.write("['%s',%d]\n"%(company.capitalize(),tweetCount))
  else:
    htmlFile.write("['%s',%d],\n"%(company.capitalize(),tweetCount))
  i=i+1

Leave a Reply

Your email address will not be published. Required fields are marked *