I wrote a script that reads and performs some data manipulation on each row from Excel Sheet. I want to see a progress bar that shows the whole progress of the operation. As you can see in the image, the progress bar is shown after every row.
Here is the code.
print('Reading Rows...')
for row in tqdm(range(2, sheet.max_row + 1)):
# Each row in the spreadsheet has data for one census tract
state = sheet['B' + str(row)].value
county = sheet['C' + str(row)].value
pop = sheet['D' + str(row)].value
# ToDo: Open a new text file and write the content of countyData to it
countyData.setdefault(state, {})
#Make sure the key for this county in this state exists.
countyData[state].setdefault(county, {'tracts':0, 'pop':0})
# Each row represnts one census tract, so increment by one
countyData[state][county]['tracts'] += 1
countyData[state][county]['pop'] += 1
#Todo: Open a new file and write the contents of countyData to it.
print('Writing results...')
resultFile = open('census2010.py', 'w')
resultFile.write('allData = ' + pprint.pformat(countyData))
resultFile.close()
print('Done')