|
3 | 3 | from io import BufferedIOBase, BytesIO, RawIOBase
|
4 | 4 | import os
|
5 | 5 | from textwrap import fill
|
6 |
| -from typing import Any, Mapping, Union |
| 6 | +from typing import Any, List, Mapping, Optional, Union |
7 | 7 |
|
8 | 8 | from pandas._config import config
|
9 | 9 |
|
10 | 10 | from pandas._libs.parsers import STR_NA_VALUES
|
11 |
| -from pandas._typing import StorageOptions |
| 11 | +from pandas._typing import Scalar, StorageOptions |
12 | 12 | from pandas.errors import EmptyDataError
|
13 | 13 | from pandas.util._decorators import Appender, deprecate_nonkeyword_arguments
|
14 | 14 |
|
@@ -398,7 +398,14 @@ def get_sheet_by_index(self, index):
|
398 | 398 | pass
|
399 | 399 |
|
400 | 400 | @abc.abstractmethod
|
401 |
| - def get_sheet_data(self, sheet, convert_float): |
| 401 | + def get_sheet_data( |
| 402 | + self, |
| 403 | + sheet, |
| 404 | + convert_float: bool, |
| 405 | + header_nrows: int, |
| 406 | + skiprows_nrows: int, |
| 407 | + nrows: Optional[int], |
| 408 | + ) -> List[List[Scalar]]: |
402 | 409 | pass
|
403 | 410 |
|
404 | 411 | def parse(
|
@@ -454,7 +461,22 @@ def parse(
|
454 | 461 | else: # assume an integer if not a string
|
455 | 462 | sheet = self.get_sheet_by_index(asheetname)
|
456 | 463 |
|
457 |
| - data = self.get_sheet_data(sheet, convert_float) |
| 464 | + if isinstance(header, int): |
| 465 | + header_nrows = header |
| 466 | + elif header is None: |
| 467 | + header_nrows = 0 |
| 468 | + else: |
| 469 | + header_nrows = max(header) |
| 470 | + if isinstance(skiprows, int): |
| 471 | + skiprows_nrows = skiprows |
| 472 | + elif skiprows is None: |
| 473 | + skiprows_nrows = 0 |
| 474 | + else: |
| 475 | + skiprows_nrows = len(skiprows) |
| 476 | + |
| 477 | + data = self.get_sheet_data( |
| 478 | + sheet, convert_float, header_nrows, skiprows_nrows, nrows |
| 479 | + ) |
458 | 480 | usecols = maybe_convert_usecols(usecols)
|
459 | 481 |
|
460 | 482 | if not data:
|
|
0 commit comments