@@ -46,6 +46,10 @@ class DateConversionError(Exception):
46
46
Row to use for the column labels of the parsed DataFrame
47
47
skiprows : list-like or integer
48
48
Row numbers to skip (0-indexed) or number of rows to skip (int)
49
+ at the start of the file
50
+ skip_footer : int, default 0
51
+ Lines at bottom of file to skip. If >0 then indicates the row to start
52
+ skipping. If <0 then skips the specified number of rows from the end.
49
53
index_col : int or sequence, default None
50
54
Column to use as the row labels of the DataFrame. If a sequence is
51
55
given, a MultiIndex is used.
@@ -81,8 +85,6 @@ class DateConversionError(Exception):
81
85
Return TextParser object
82
86
chunksize : int, default None
83
87
Return TextParser object for iteration
84
- skip_footer : int, default 0
85
- Number of line at bottom of file to skip
86
88
converters : dict. optional
87
89
Dict of functions for converting values in certain columns. Keys can either
88
90
be integers or column labels
@@ -476,7 +478,7 @@ def __init__(self, f, delimiter=None, dialect=None, names=None, header=0,
476
478
else :
477
479
self .converters = {}
478
480
479
- assert (self .skip_footer >= 0 )
481
+ # assert(self.skip_footer >= 0)
480
482
481
483
self .keep_default_na = keep_default_na
482
484
if na_values is None and keep_default_na :
@@ -771,14 +773,17 @@ def _rows_to_cols(self, content):
771
773
772
774
if col_len != zip_len :
773
775
row_num = - 1
776
+ i = 0
774
777
for (i , l ) in enumerate (content ):
775
778
if len (l ) != col_len :
776
779
break
777
780
778
781
footers = 0
779
782
if self .skip_footer :
780
783
footers = self .skip_footer
781
- row_num = self .pos - (len (content ) - i + footers )
784
+ if footers > 0 :
785
+ footers = footers - self .pos
786
+ row_num = self .pos - (len (content ) - i - footers )
782
787
783
788
msg = ('Expecting %d columns, got %d in row %d' %
784
789
(col_len , zip_len , row_num ))
@@ -1101,7 +1106,7 @@ def _get_lines(self, rows=None):
1101
1106
self .buf = []
1102
1107
1103
1108
if self .skip_footer :
1104
- lines = lines [:- self .skip_footer ]
1109
+ lines = lines [:self .skip_footer ]
1105
1110
1106
1111
lines = self ._check_comments (lines )
1107
1112
return self ._check_thousands (lines )
0 commit comments