API documentation
ixbrlparse.IXBRL
Parse an iXBRL file.
Source code in src/ixbrlparse/core.py
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 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
|
__init__(f, raise_on_error=True)
Constructor for the IXBRL class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
IO
|
File-like object to parse. |
required |
raise_on_error
|
bool
|
Whether to raise an exception on error |
True
|
Source code in src/ixbrlparse/core.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
open(filename, raise_on_error=True)
classmethod
Open an iXBRL file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
Union[str, Path]
|
Path to file to parse. |
required |
raise_on_error
|
bool
|
Whether to raise an exception on error |
True
|
Source code in src/ixbrlparse/core.py
321 322 323 324 325 326 327 328 329 330 |
|
to_json()
Return a JSON representation of the iXBRL file.
Returns:
Type | Description |
---|---|
dict
|
A dictionary containing the following keys:
|
Source code in src/ixbrlparse/core.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
to_table(fields='numeric')
Return a list of dictionaries representing the iXBRL file.
This is suitable for passing to pandas.DataFrame.from_records().
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fields
|
str
|
Which fields to include in the output. Can be "numeric", "nonnumeric" or "all". |
'numeric'
|
Returns:
Type | Description |
---|---|
list[dict]
|
A list of dictionaries representing the iXBRL file. |
The fields included are:
- schema (str)
- name (str) -- the name of the element
- value -- the value of the element. Can be number, str, None, or boolean
- unit (str) -- the unit of the element if present
- instant (date) -- the instant date of the element context if present
- startdate (date) -- the start date of the element context if present
- enddate (date) -- the end date of the element context if present
- segment:N (str) -- the Nth segment of the element context if present (can be repeated)
Examples:
>>> import pandas as pd
>>> i = IXBRL.open("tests/fixtures/ixbrl/uk-gaap/2009-12-31/Company-Accounts-Data.xml")
>>> df = pd.DataFrame.from_records(i.to_table(fields="numeric"))
>>> df.head()
Source code in src/ixbrlparse/core.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
|
ixbrlparse.ixbrlFormat
Class to represent an ixbrl format.
This class should generally be subclassed to provide additional functionality.
Attributes:
Name | Type | Description |
---|---|---|
format_names |
tuple[str, ...]
|
A tuple of format names that this class should be used for. |
Source code in src/ixbrlparse/components/_base.py
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 |
|
__init__(format_, decimals=None, scale=0, sign=None)
Initialise the ixbrl format object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
format_
|
str
|
The name of the format. |
required |
decimals
|
Optional[Union[int, str]]
|
The number of decimal places (only used for numeric formats). |
None
|
scale
|
Union[int, str]
|
The scale of the format (only for numeric formats). If more than 0 this value is used as the exponent for a value, so for example with a scale of 4 and a value of 20, the parsed value is 20 * (10 ^ 4) == 200000. |
0
|
sign
|
Optional[str]
|
The sign of the format (only for numeric formats). The sign given is usually "-" or empty. |
None
|
Source code in src/ixbrlparse/components/_base.py
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 |
|
parse_value(value)
Parse a value using the format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Union[str, int, float]
|
The value to parse. |
required |
Returns:
Type | Description |
---|---|
Optional[Union[int, float, bool, date, str]]
|
The parsed value in the appropriate python type. |
Source code in src/ixbrlparse/components/_base.py
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 |
|
to_json()
Convert the object to a JSON serialisable dictionary.
Source code in src/ixbrlparse/components/_base.py
63 64 65 |
|
ixbrlparse.ixbrlContext
Class to represent an ixbrl context.
The context should either have an instant date or a start and end date.
Attributes:
Name | Type | Description |
---|---|---|
id |
The id of the context. |
|
entity |
A dictionary of the entity information. |
|
segments |
A list of dictionaries of the segment information. |
|
instant |
Optional[date]
|
The instant date of the context. |
startdate |
Optional[date]
|
The start date of the context. |
enddate |
Optional[date]
|
The end date of the context. |
Source code in src/ixbrlparse/components/context.py
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 |
|
to_json()
Convert the object to a JSON serialisable dictionary.
Source code in src/ixbrlparse/components/context.py
55 56 57 58 59 60 61 |
|
ixbrlparse.ixbrlNonNumeric
Models a non-numeric element in an iXBRL document
Non-numeric elements are used to store information such as the name of the entity, the name of the reporting period, etc. The value of non-numeric elements is always a string, so we don't need to worry about parsing the string.
Source code in src/ixbrlparse/components/nonnumeric.py
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 |
|
__init__(context=None, name=None, format_=None, value=None, soup_tag=None)
Constructor for the ixbrlNonNumeric class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
ixbrlContext
|
The context of the non-numeric element |
None
|
name
|
str
|
The name of the non-numeric element |
None
|
format_
|
str
|
The format of the non-numeric element |
None
|
value
|
str
|
The value of the non-numeric element |
None
|
soup_tag
|
Tag
|
The source tag in beautiful soup |
None
|
Source code in src/ixbrlparse/components/nonnumeric.py
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 |
|
ixbrlparse.ixbrlNumeric
Models a numeric element in an iXBRL document
Source code in src/ixbrlparse/components/numeric.py
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 |
|
__init__(name=None, unit=None, value=None, text=None, context=None, soup_tag=None, **attrs)
Constructor for the ixbrlNumeric class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the numeric element |
None
|
unit
|
str
|
The unit of the numeric element |
None
|
value
|
float
|
The value of the numeric element |
None
|
text
|
str
|
The text of the numeric element |
None
|
context
|
ixbrlContext
|
The context of the numeric element |
None
|
soup_tag
|
Tag
|
The source tag in beautiful soup |
None
|
Source code in src/ixbrlparse/components/numeric.py
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 |
|