-1

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.

snapshot: enter image description here

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')

jabbar
  • 23
  • 4

1 Answers1

0

Could you remove this line

print('Writing results...')

and see if it still shows that way , probably the print statement causes it.

For example look at the following code

for i in tqdm(range(int(9e6))):
    if(i%10000==0):
        print("hello")
    pass

A new progress bar will be shown after the hello message , and removing the print statement solves it.