text_csv¶
Strategy class for parser/csv.
CSVDialect: type[Enum] = Enum(value='CSVDialect', names={dialect.upper(): dialectfor dialect in csv.list_dialects()}, module=__name__, type=str)
module-attribute
¶
CSV dialects.
All available dialects are retrieved through the csv.list_dialects()
function,
and will thus depend on the currently loaded and used Python interpreter.
CSVConfig
¶
Bases: AttrDict
CSV parse-specific Configuration Data Model.
Source code in oteapi/strategies/parse/text_csv.py
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 |
|
datacache_config: Optional[DataCacheConfig] = Field(None, description='Configurations for the data cache for storing the downloaded file content.')
class-attribute
instance-attribute
¶
dialect: DialectFormatting = Field(DialectFormatting(), description='Dialect and formatting parameters. See [the Python docs](https://docs.python.org/3/library/csv.html#csv-fmt-params) for more information.')
class-attribute
instance-attribute
¶
downloadUrl: Optional[HostlessAnyUrl] = Field(None, description=ResourceConfig.model_fields['downloadUrl'].description)
class-attribute
instance-attribute
¶
mediaType: Literal['text/csv'] = Field('text/csv', description=ResourceConfig.model_fields['mediaType'].description)
class-attribute
instance-attribute
¶
reader: ReaderConfig = Field(ReaderConfig(), description='CSV DictReader configuration parameters. See [the Python docs](https://docs.python.org/3/library/csv.html#csv.DictReader) for more information.')
class-attribute
instance-attribute
¶
CSVParseContent
¶
Bases: AttrDict
Class for returning values from CSV Parse.
Source code in oteapi/strategies/parse/text_csv.py
273 274 275 276 277 278 |
|
content: dict[Union[str, None], list[Any]] = Field(..., description='Content of the CSV document.')
class-attribute
instance-attribute
¶
CSVParseStrategy
¶
Parse strategy for CSV files.
Source code in oteapi/strategies/parse/text_csv.py
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 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
parse_config: CSVParserConfig
instance-attribute
¶
get()
¶
Parse CSV.
Source code in oteapi/strategies/parse/text_csv.py
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 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
initialize()
¶
Initialize.
Source code in oteapi/strategies/parse/text_csv.py
287 288 289 |
|
CSVParserConfig
¶
Bases: ParserConfig
CSV parse strategy filter config.
Source code in oteapi/strategies/parse/text_csv.py
261 262 263 264 265 266 267 268 269 270 |
|
DialectFormatting
¶
Bases: BaseModel
Dialect and formatting parameters for CSV.
See the Python docs for more information.
Note
As Dialect.lineterminator
is hardcoded in csv.reader
, it is left out of
this model.
Source code in oteapi/strategies/parse/text_csv.py
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 |
|
base: Optional[CSVDialect] = Field(None, description="A specific CSV dialect, e.g., 'excel'. Any other parameters here will overwrite the preset dialect parameters for the specified dialect.")
class-attribute
instance-attribute
¶
delimiter: Optional[str] = Field(None, description='A one-character string used to separate fields. See [the Python docs entry](https://docs.python.org/3/library/csv.html#csv.Dialect.delimiter) for more information.', min_length=1, max_length=1)
class-attribute
instance-attribute
¶
doublequote: Optional[bool] = Field(None, description='Controls how instances of [`quotechar`][oteapi.strategies.parse.text_csv.DialectFormatting.quotechar] appearing inside a field should themselves be quoted. When `True`, the character is doubled. When `False`, the [`escapechar`][oteapi.strategies.parse.text_csv.DialectFormatting.escapechar] is used as a prefix to the [`quotechar`][oteapi.strategies.parse.text_csv.DialectFormatting.quotechar]. See [the Python docs entry](https://docs.python.org/3/library/csv.html#csv.Dialect.doublequote) for more information.')
class-attribute
instance-attribute
¶
escapechar: Optional[str] = Field(None, description='A one-character string used by the writer to escape the [`delimiter`][oteapi.strategies.parse.text_csv.DialectFormatting.delimiter] if [`quoting`][oteapi.strategies.parse.text_csv.DialectFormatting.quoting] is set to [`QUOTE_NONE`][oteapi.strategies.parse.text_csv.QuoteConstants.QUOTE_NONE] and the [`quotechar`][oteapi.strategies.parse.text_csv.DialectFormatting.quotechar] if [`doublequote`][oteapi.strategies.parse.text_csv.DialectFormatting.doublequote] is `False`. On reading, the [`escapechar`][oteapi.strategies.parse.text_csv.DialectFormatting.escapechar] removes any special meaning from the following character. See [the Python docs entry](https://docs.python.org/3/library/csv.html#csv.Dialect.escapechar) for more information.', min_length=1, max_length=1)
class-attribute
instance-attribute
¶
quotechar: Optional[str] = Field(None, description='A one-character string used to quote fields containing special characters, such as the [`delimiter`][oteapi.strategies.parse.text_csv.DialectFormatting.delimiter] or [`quotechar`][oteapi.strategies.parse.text_csv.DialectFormatting.quotechar], or which contain new-line characters. See [the Python docs entry](https://docs.python.org/3/library/csv.html#csv.Dialect.quotechar) for more information.', min_length=1, max_length=1)
class-attribute
instance-attribute
¶
quoting: Optional[QuoteConstants] = Field(None, description='Controls when quotes should be generated by the writer and recognised by the reader. It can take on any of the `QUOTE_*` constants (see section [Module Contents](https://docs.python.org/3/library/csv.html#csv-contents)). See [the Python docs entry](https://docs.python.org/3/library/csv.html#csv.Dialect.quoting) for more information.')
class-attribute
instance-attribute
¶
skipinitialspace: Optional[bool] = Field(None, description='When `True`, whitespace immediately following the [`delimiter`][oteapi.strategies.parse.text_csv.DialectFormatting.delimiter] is ignored. See [the Python docs entry](https://docs.python.org/3/library/csv.html#csv.Dialect.skipinitialspace) for more information.')
class-attribute
instance-attribute
¶
strict: Optional[bool] = Field(None, description='When `True`, raise exception [Error](https://docs.python.org/3/library/csv.html#csv.Error) on bad CSV input. See [the Python docs entry](https://docs.python.org/3/library/csv.html#csv.Dialect.strict) for more information.')
class-attribute
instance-attribute
¶
validate_dialect_base(value)
classmethod
¶
Ensure the given base
dialect is registered locally.
Source code in oteapi/strategies/parse/text_csv.py
172 173 174 175 176 177 178 179 180 181 |
|
QuoteConstants
¶
Bases: str
, Enum
CSV module QUOTE_*
constants.
Source code in oteapi/strategies/parse/text_csv.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
QUOTE_ALL = 'QUOTE_ALL'
class-attribute
instance-attribute
¶
QUOTE_MINIMAL = 'QUOTE_MINIMAL'
class-attribute
instance-attribute
¶
QUOTE_NONE = 'QUOTE_NONE'
class-attribute
instance-attribute
¶
QUOTE_NONUMERIC = 'QUOTE_NONNUMERIC'
class-attribute
instance-attribute
¶
csv_constant()
¶
Return the CSV lib equivalent constant.
Source code in oteapi/strategies/parse/text_csv.py
39 40 41 42 43 44 45 46 |
|
ReaderConfig
¶
Bases: BaseModel
CSV DictReader configuration parameters.
See the Python docs for more information.
Source code in oteapi/strategies/parse/text_csv.py
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 |
|