excel_xlsx¶
Strategy class for workbook/xlsx.
XLSXParseConfig
¶
Bases: AttrDict
Data model for retrieving a rectangular section of an Excel sheet.
Source code in oteapi/strategies/parse/excel_xlsx.py
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 |
|
col_from: Optional[Union[int, str]] = Field(None, description='Excel column number or label of first column. Defaults to first assigned column.')
class-attribute
instance-attribute
¶
col_to: Optional[Union[int, str]] = Field(None, description='Excel column number or label of last column. Defaults to last assigned column.')
class-attribute
instance-attribute
¶
datacache_config: Optional[DataCacheConfig] = Field(None, description='Configurations for the data cache for retrieving the downloaded file content.')
class-attribute
instance-attribute
¶
downloadUrl: Optional[HostlessAnyUrl] = Field(None, description=ResourceConfig.model_fields['downloadUrl'].description)
class-attribute
instance-attribute
¶
download_config: AttrDict = Field(AttrDict(), description='Configurations provided to a download strategy.')
class-attribute
instance-attribute
¶
header: Optional[list[str]] = Field(None, description='Optional list of column names, specifying the columns to return. These names they should match cells in `header_row`.')
class-attribute
instance-attribute
¶
header_row: Optional[int] = Field(None, description='Row number with the headers. Defaults to `1` if header is given, otherwise `None`.')
class-attribute
instance-attribute
¶
mediaType: Literal['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'] = Field('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', description=ResourceConfig.model_fields['mediaType'].description)
class-attribute
instance-attribute
¶
new_header: Optional[list[str]] = Field(None, description='Optional list of new column names replacing `header` in the output.')
class-attribute
instance-attribute
¶
row_from: Optional[int] = Field(None, description='Excel row number of first row. Defaults to first assigned row.')
class-attribute
instance-attribute
¶
row_to: Optional[int] = Field(None, description='Excel row number of last row. Defaults to last assigned row.')
class-attribute
instance-attribute
¶
worksheet: str = Field(..., description='Name of worksheet to load.')
class-attribute
instance-attribute
¶
XLSXParseContent
¶
Bases: AttrDict
Class for returning values from XLSXParse.
Source code in oteapi/strategies/parse/excel_xlsx.py
30 31 32 33 34 35 36 |
|
data: dict[str, list] = Field(..., description='A dict with column-name/column-value pairs. The values are lists.')
class-attribute
instance-attribute
¶
XLSXParseParserConfig
¶
Bases: ParserConfig
XLSX parse strategy resource config.
Source code in oteapi/strategies/parse/excel_xlsx.py
109 110 111 112 113 114 115 116 117 118 |
|
configuration: XLSXParseConfig = Field(..., description='SQLite parse strategy-specific configuration.')
class-attribute
instance-attribute
¶
parserType: Literal['parser/excel_xlsx'] = Field('parser/excel_xlsx', description=ParserConfig.model_fields['parserType'].description)
class-attribute
instance-attribute
¶
XLSXParseStrategy
¶
Parse strategy for Excel XLSX files.
Registers strategies:
("parserType", "excel_xlsx")
Source code in oteapi/strategies/parse/excel_xlsx.py
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 |
|
parse_config: XLSXParseParserConfig
instance-attribute
¶
get()
¶
Parses selected region of an excel file.
Returns:
Type | Description |
---|---|
XLSXParseContent
|
A dict with column-name/column-value pairs. The values are lists. |
Source code in oteapi/strategies/parse/excel_xlsx.py
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 |
|
initialize()
¶
Initialize.
Source code in oteapi/strategies/parse/excel_xlsx.py
188 189 190 |
|
get_column_indices(model, worksheet)
¶
Helper function returning a list of column indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
XLSXParseConfig
|
The parsed data model. |
required |
worksheet |
Worksheet
|
Excel worksheet, from which the header values will be retrieved. |
required |
Returns:
Type | Description |
---|---|
Iterable[int]
|
A list of column indices. |
Source code in oteapi/strategies/parse/excel_xlsx.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
set_model_defaults(model, worksheet)
¶
Update data model model
with default values obtained from worksheet
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
XLSXParseConfig
|
The parsed data model. |
required |
worksheet |
Worksheet
|
Excel worksheet, from which the default values will be obtained. |
required |
Source code in oteapi/strategies/parse/excel_xlsx.py
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 |
|