diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 4a501573c8cc4..fa1904a8fb955 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2083,10 +2083,10 @@ def _infer_columns(self): # We have an empty file, so check # if columns are provided. That will # serve as the 'line' for parsing - if have_mi_columns: + if have_mi_columns and hr > 0: if clear_buffer: self._clear_buffer() - columns.append([None] * len(this_columns)) + columns.append([None] * len(columns[-1])) return columns, num_original_columns if not self.names: diff --git a/pandas/parser.pyx b/pandas/parser.pyx index 3376b338685f1..0b1c9eba63ba7 100644 --- a/pandas/parser.pyx +++ b/pandas/parser.pyx @@ -718,7 +718,7 @@ cdef class TextReader: # e.g., if header=3 and file only has 2 lines elif (self.parser.lines < hr + 1 - and not isinstance(self.orig_header, list)) or ( + and not isinstance(self.orig_header, list)) or ( self.parser.lines < hr): msg = self.orig_header if isinstance(msg, list):