I'm trying to display a progress bar whenever a file is loaded into pandas. But all I get back is this.
0it [00:00, ?it/s]
Here is the code I'm working with.
I'm importing tqdm based on some examples that I've found.
from tqdm import tqdm
...
def function(self):
params = self.getGuiParams()
filename = params['fileNameLineEdit']
keyname = params['dataSetNameLineEdit']
try:
print('Loading data file: ' + str(filename))
self.datakeys.append(keyname)
chunksize = 50000
df = tqdm(pd.read_csv(filename, header=[0, 1], chunksize=chunksize, iterator=True))
self.data[keyname] = spectral_data(df)
except Exception as e:
print('Problem reading data: {}'.format(e))
tqdm
requires an iterator. While you are using theiterator=True
option forread_csv
, you are assigning the resultingTextFileReader
object back todf
, without actually iterating on it.Try something like:
I've never used tqdm so that may not work out of the box - you might need to calculate file size and how many chunks that will take etc.