-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path_fastexcel.pyi
More file actions
324 lines (294 loc) · 10.6 KB
/
_fastexcel.pyi
File metadata and controls
324 lines (294 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
from __future__ import annotations
import typing
from collections.abc import Callable
from typing import TYPE_CHECKING, Literal
if TYPE_CHECKING:
import pyarrow as pa
DType = Literal["null", "int", "float", "string", "boolean", "datetime", "date", "duration"]
DTypeMap = dict[str | int, DType]
ColumnNameFrom = Literal["provided", "looked_up", "generated"]
DTypeFrom = Literal["provided_for_all", "provided_by_index", "provided_by_name", "guessed"]
SheetVisible = Literal["visible", "hidden", "veryhidden"]
class ColumnInfoNoDtype:
def __init__(
self,
*,
name: str,
index: int,
absolute_index: int,
column_name_from: ColumnNameFrom,
) -> None: ...
@property
def name(self) -> str: ...
@property
def index(self) -> int: ...
@property
def absolute_index(self) -> int: ...
@property
def column_name_from(self) -> ColumnNameFrom: ...
class ColumnInfo:
def __init__(
self,
*,
name: str,
index: int,
absolute_index: int,
column_name_from: ColumnNameFrom,
dtype: DType,
dtype_from: DTypeFrom,
) -> None: ...
@property
def name(self) -> str: ...
@property
def index(self) -> int: ...
@property
def absolute_index(self) -> int: ...
@property
def dtype(self) -> DType: ...
@property
def column_name_from(self) -> ColumnNameFrom: ...
@property
def dtype_from(self) -> DTypeFrom: ...
class DefinedName:
def __init__(
self,
*,
name: str,
formula: str,
) -> None: ...
@property
def name(self) -> str: ...
@property
def formula(self) -> str: ...
class CellError:
@property
def position(self) -> tuple[int, int]: ...
@property
def row_offset(self) -> int: ...
@property
def offset_position(self) -> tuple[int, int]: ...
@property
def detail(self) -> str: ...
def __repr__(self) -> str: ...
class CellErrors:
@property
def errors(self) -> list[CellError]: ...
def __repr__(self) -> str: ...
class _ExcelSheet:
@property
def name(self) -> str:
"""The name of the sheet"""
@property
def width(self) -> int:
"""The sheet's width"""
@property
def height(self) -> int:
"""The sheet's height"""
@property
def total_height(self) -> int:
"""The sheet's total height"""
@property
def offset(self) -> int:
"""The sheet's offset before data starts"""
@property
def selected_columns(self) -> list[ColumnInfo]:
"""The sheet's selected columns"""
def available_columns(self) -> list[ColumnInfo]:
"""The columns available for the given sheet"""
@property
def specified_dtypes(self) -> DTypeMap | None:
"""The dtypes specified for the sheet"""
@property
def visible(self) -> SheetVisible:
"""The visibility of the sheet"""
def to_arrow(self) -> pa.RecordBatch:
"""Converts the sheet to a pyarrow `RecordBatch`
Requires the `pyarrow` extra to be installed.
"""
def to_arrow_with_errors(self) -> tuple[pa.RecordBatch, CellErrors]:
"""Converts the sheet to a pyarrow `RecordBatch` with error information.
Stores the positions of any values that cannot be parsed as the specified type and were
therefore converted to None.
Requires the `pyarrow` extra to be installed.
"""
def __arrow_c_schema__(self) -> object:
"""Export the schema as an `ArrowSchema` `PyCapsule`.
https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html#arrowschema-export
The Arrow PyCapsule Interface enables zero-copy data exchange with
Arrow-compatible libraries without requiring PyArrow as a dependency.
"""
def __arrow_c_array__(self, requested_schema: object = None) -> tuple[object, object]:
"""Export the schema and data as a pair of `ArrowSchema` and `ArrowArray` `PyCapsules`.
The optional `requested_schema` parameter allows for potential schema conversion.
https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html#arrowarray-export
The Arrow PyCapsule Interface enables zero-copy data exchange with
Arrow-compatible libraries without requiring PyArrow as a dependency.
"""
class _ExcelTable:
@property
def name(self) -> str:
"""The name of the table"""
@property
def sheet_name(self) -> str:
"""The name of the sheet this table belongs to"""
@property
def width(self) -> int:
"""The table's width"""
@property
def height(self) -> int:
"""The table's height"""
@property
def total_height(self) -> int:
"""The table's total height"""
@property
def offset(self) -> int:
"""The table's offset before data starts"""
@property
def selected_columns(self) -> list[ColumnInfo]:
"""The table's selected columns"""
def available_columns(self) -> list[ColumnInfo]:
"""The columns available for the given table"""
@property
def specified_dtypes(self) -> DTypeMap | None:
"""The dtypes specified for the table"""
def to_arrow(self) -> pa.RecordBatch:
"""Converts the table to a pyarrow `RecordBatch`
Requires the `pyarrow` extra to be installed.
"""
def __arrow_c_schema__(self) -> object:
"""Export the schema as an `ArrowSchema` `PyCapsule`.
https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html#arrowschema-export
The Arrow PyCapsule Interface enables zero-copy data exchange with
Arrow-compatible libraries without requiring PyArrow as a dependency.
"""
def __arrow_c_array__(self, requested_schema: object = None) -> tuple[object, object]:
"""Export the schema and data as a pair of `ArrowSchema` and `ArrowArray` `PyCapsules`.
The optional `requested_schema` parameter allows for potential schema conversion.
https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html#arrowarray-export
The Arrow PyCapsule Interface enables zero-copy data exchange with
Arrow-compatible libraries without requiring PyArrow as a dependency.
"""
class _ExcelReader:
"""A class representing an open Excel file and allowing to read its sheets"""
@typing.overload
def load_sheet(
self,
idx_or_name: str | int,
*,
header_row: int | None = 0,
column_names: list[str] | None = None,
skip_rows: int | list[int] | Callable[[int], bool] | None = None,
n_rows: int | None = None,
schema_sample_rows: int | None = 1_000,
dtype_coercion: Literal["coerce", "strict"] = "coerce",
use_columns: list[str]
| list[int]
| str
| Callable[[ColumnInfoNoDtype], bool]
| None = None,
dtypes: DType | DTypeMap | None = None,
eager: Literal[False] = ...,
skip_whitespace_tail_rows: bool = False,
whitespace_as_null: bool = False,
) -> _ExcelSheet: ...
@typing.overload
def load_sheet(
self,
idx_or_name: str | int,
*,
header_row: int | None = 0,
column_names: list[str] | None = None,
skip_rows: int | list[int] | Callable[[int], bool] | None = None,
n_rows: int | None = None,
schema_sample_rows: int | None = 1_000,
dtype_coercion: Literal["coerce", "strict"] = "coerce",
use_columns: list[str]
| list[int]
| str
| Callable[[ColumnInfoNoDtype], bool]
| None = None,
dtypes: DType | DTypeMap | None = None,
eager: Literal[True] = ...,
skip_whitespace_tail_rows: bool = False,
whitespace_as_null: bool = False,
) -> pa.RecordBatch: ...
@typing.overload
def load_sheet(
self,
idx_or_name: str | int,
*,
header_row: int | None = 0,
column_names: list[str] | None = None,
skip_rows: int | list[int] | Callable[[int], bool] | None = None,
n_rows: int | None = None,
schema_sample_rows: int | None = 1_000,
dtype_coercion: Literal["coerce", "strict"] = "coerce",
use_columns: list[str]
| list[int]
| str
| Callable[[ColumnInfoNoDtype], bool]
| None = None,
dtypes: DType | DTypeMap | None = None,
eager: bool = False,
skip_whitespace_tail_rows: bool = False,
whitespace_as_null: bool = False,
) -> pa.RecordBatch: ...
@typing.overload
def load_table(
self,
name: str,
*,
header_row: int | None = None,
column_names: list[str] | None = None,
skip_rows: int | list[int] | Callable[[int], bool] | None = None,
n_rows: int | None = None,
schema_sample_rows: int | None = 1_000,
dtype_coercion: Literal["coerce", "strict"] = "coerce",
use_columns: list[str]
| list[int]
| str
| Callable[[ColumnInfoNoDtype], bool]
| None = None,
dtypes: DType | DTypeMap | None = None,
eager: Literal[False] = ...,
skip_whitespace_tail_rows: bool = False,
whitespace_as_null: bool = False,
) -> _ExcelTable: ...
@typing.overload
def load_table(
self,
name: str,
*,
header_row: int | None = None,
column_names: list[str] | None = None,
skip_rows: int | list[int] | Callable[[int], bool] | None = None,
n_rows: int | None = None,
schema_sample_rows: int | None = 1_000,
dtype_coercion: Literal["coerce", "strict"] = "coerce",
use_columns: list[str]
| list[int]
| str
| Callable[[ColumnInfoNoDtype], bool]
| None = None,
dtypes: DType | DTypeMap | None = None,
eager: Literal[True] = ...,
skip_whitespace_tail_rows: bool = False,
whitespace_as_null: bool = False,
) -> pa.RecordBatch: ...
@property
def sheet_names(self) -> list[str]: ...
def table_names(self, sheet_name: str | None = None) -> list[str]: ...
def defined_names(self) -> list[DefinedName]: ...
def read_excel(source: str | bytes) -> _ExcelReader:
"""Reads an excel file and returns an ExcelReader"""
__version__: str
# Exceptions
class FastExcelError(Exception): ...
class UnsupportedColumnTypeCombinationError(FastExcelError): ...
class CannotRetrieveCellDataError(FastExcelError): ...
class CalamineCellError(FastExcelError): ...
class CalamineError(FastExcelError): ...
class SheetNotFoundError(FastExcelError): ...
class ColumnNotFoundError(FastExcelError): ...
class ArrowError(FastExcelError): ...
class InvalidParametersError(FastExcelError): ...