From 494b180859a929fcea3a1e173fdf3174b88aaa8b Mon Sep 17 00:00:00 2001 From: ask Elias Date: Mon, 22 Dec 2014 14:44:38 +0100 Subject: [PATCH] fix harelba/q#62 --- bin/q | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/q b/bin/q index 62b7894e..fb9ae90e 100755 --- a/bin/q +++ b/bin/q @@ -523,6 +523,10 @@ class TableColumnInferer(object): if self.expected_column_count is not None: self.column_count = self.expected_column_count else: + # If no rows and has header_row, take the header_row + if not len(column_count_list) and len(self.header_row): + self.column_count = len(self.header_row) + return # If not specified, we'll take the largest row in the sample rows self.column_count = max(column_count_list) @@ -737,7 +741,7 @@ class TableCreator(object): self._insert_row(col_vals) if stop_after_analysis and self.column_inferer.inferred: return - if mfs.lines_read == 0 or (mfs.lines_read == 1 and self.skip_header): + if mfs.lines_read == 0: raise EmptyDataException() except StrictModeColumnCountMismatchException,e: raise ColumnCountMismatchException( @@ -1357,7 +1361,7 @@ class QOutputPrinter(object): if formatting_dict is not None and str(i + 1) in formatting_dict.keys(): fmt_str = formatting_dict[str(i + 1)] else: - if self.output_params.beautify: + if self.output_params.beautify and i in max_lengths: fmt_str = "%%-%ss" % max_lengths[i] else: fmt_str = "%s"