diff --git a/cliff/formatters/table.py b/cliff/formatters/table.py index 1813e3e7..43066b47 100644 --- a/cliff/formatters/table.py +++ b/cliff/formatters/table.py @@ -32,14 +32,18 @@ class TableLister(ListFormatter): # first row and set the alignment of the # output accordingly. data_iter = iter(data) - first_row = next(data_iter) - for value, name in zip(first_row, column_names): - alignment = self.ALIGNMENTS.get(type(value), 'l') - x.set_field_align(name, alignment) - # Now iterate over the data and add the rows. - x.add_row(first_row) - for row in data_iter: - x.add_row(row) + try: + first_row = next(data_iter) + except StopIteration: + pass + else: + for value, name in zip(first_row, column_names): + alignment = self.ALIGNMENTS.get(type(value), 'l') + x.set_field_align(name, alignment) + # Now iterate over the data and add the rows. + x.add_row(first_row) + for row in data_iter: + x.add_row(row) formatted = x.get_string(fields=(parsed_args.columns or column_names)) stdout.write(formatted) stdout.write('\n')