Skip to content
Snippets Groups Projects
Commit 9718eaea authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

handle progress bar for dataframes

parent aa3afefd
No related branches found
No related tags found
No related merge requests found
Pipeline #9899 passed
......@@ -74,7 +74,7 @@ class ImportTask(object):
pass
def _process_rows(self, rows):
for row in rows:
for idx, row in enumerate(rows):
try:
new_object = None
with transaction.atomic():
......@@ -93,6 +93,8 @@ class ImportTask(object):
if self.progress_bar == False:
self.out_stream.write(self.style.SUCCESS(
'Successfully inserted {}'.format(new_object)))
if self.progress_bar:
self.rows.update(idx)
def count_source(self):
self.source_count = len(self.rows)
......@@ -101,7 +103,7 @@ class ImportTask(object):
self.open_data_source()
self.count_source()
if self.progress_bar is True:
with click.progressbar(self.rows,
with click.progressbar(length=self.source_count,
label='Importing ' + self.description + ' (' + str(self.source_count) + ' rows to process).') as rows_list:
self._process_rows(rows_list)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment