I want to be able to insert a kind of progress bar to this script as it takes a while to load
python does have a progress-bar package http://code.google.com/p/python-progressbar/
once installed this is how you might use it.
from progressbar import Bar, ETA, Percentage, ProgressBar, RotatingMarker
csvReader = csv.reader(open(fo, 'rb'), delimiter=',')
csvList = list(csvReader)
#print len(csvList)
#return
count = 1
widgets = ['Parsing CSV: ', Percentage(), ' ', Bar(marker = RotatingMarker()), ' ', ETA()]
pbar = ProgressBar(widgets = widgets, maxval = 50000).start()
for index, row in enumerate(csvList[:50000]):
if count != 1:
cur.execute(sql2, [row[0], row[2], row[9], row[11], row[18], row[25], row[27], row[15], row[22]])
count +=1
pbar.update(index)
pbar.finish()
cnn.close()
you can change the rate of the update by playing around with maxval
and update
.