How do you query entire tables in the SEC filing
Based on the description of Edgartools, it is very convenient to query facts and so forth. But how would you lets say query an entire table (not financial statements like shown below.
The original code for this:
from edgar.xbrl import XBRL company = Company("XOM") filing = company.latest("10-K") xb = filing.xbrl() results = (xb.query() .by_concept("us-gaap:ScheduleOfInventoryCurrentTableTextBlock") ) results
Result Dataframe:
Whats really in the XBRL
Here is the original source https://www.sec.gov/ix?doc=/Archives/edgar/data/0000034088/000003408825000010/xom-20241231.htm#fact-identifier-1154
To me I think this is a important issue for filings because theres a lot of useful little tables for specific sectors like energy, and tech (data centers) and so forth. So if there is a solution, would there be documentation in the manual then?
I think you mean query for the concept and render the HTML if it is a TableBlock. I think that is doable as a feature request
I agree this could be a feature request but would this be allowed afterwards be like
df = textblock.todataframe()
Or be allowed in such a way to allow to parse the table out from the textblock to put in a nice dataframe.
Triage Summary
Thank you for this feature request! This is a valuable enhancement that would make industry-specific tables much more accessible.
Classification
Type: Feature Request (Enhancement) Priority: MEDIUM (P2) - Priority Score: 16 Target Release: v4.30.0 or v4.31.0 (Q1 2025) Estimated Effort: 2 days (Medium) Tracking: Created internal issue edgartools-a8d
Analysis
This feature aligns well with EdgarTools' mission of making SEC data elegantly accessible. It would:
✅ Fill an API Gap: TableTextBlock concepts currently return metadata, not the actual table data
✅ Beginner-Friendly: Extends familiar .query().by_concept() API with .extract_tables()
✅ Leverage Existing Code: EdgarTools already has production-ready table extraction (TableNode.to_dataframe())
✅ Pandas-First: Natural integration with data science workflows
Proposed API Design
We're considering an API like this:
from edgar import Company
company = Company("XOM")
filing = company.latest("10-K")
xbrl = filing.xbrl()
# Extract tables from TableTextBlock concept
tables = (xbrl.query()
.by_concept("us-gaap:ScheduleOfInventoryCurrentTableTextBlock")
.extract_tables()) # Returns List[pd.DataFrame]
# Access first table
inventory_table = tables[0]
print(inventory_table.head())
Design Questions for Community Feedback
Before implementing, we'd like input on:
- Method naming:
.extract_tables(),.to_dataframe(), or.render_tables()? - Multi-table handling: How should we handle concepts with multiple tables?
- Return list of DataFrames (most flexible)
- Return merged DataFrame with multi-index
- Require explicit table index selection
- Missing table behavior: What if concept exists but no table found?
- Return
None - Raise
TableNotFoundexception - Return empty DataFrame
- Return
Current Workaround
While we evaluate this feature, you can extract tables manually using the document API:
from edgar import Company
company = Company("XOM")
filing = company.latest("10-K")
# Parse the HTML document
doc = filing.document()
# Find tables - the document tree provides access to all tables
# You can then use .to_dataframe() on individual table nodes
# You'll need to identify which table corresponds to your concept
Timeline
- Triage Complete: ✅ (This update)
- API Design Discussion: Next 1-2 weeks (community feedback welcome!)
- Implementation: Planned for v4.30.0 or v4.31.0 (Q1 2025) depending on prioritization
- Tracking: Created internal tracking issue (edgartools-a8d)
We appreciate the detailed example in your issue - it helps us understand the use case perfectly! Feel free to share any additional thoughts on the API design questions above.
Related: This feature would also enable extraction of other industry-specific tables (segment data for tech companies, loan schedules for banks, property details for REITs, etc.).
Yes, this is a genius plan to extract all the small tables and then access each specific table.
But Ill answer all three questions
- extract.tables is probably the simplest to remember personally.
- I would return the list of DataFrames
- I think the TableNotFound would be the easiest one for users. This way users can report errors with the API faster.
We already have the fundamental code to do this in edgartools so it's possible to find these blocks. There may be some complication in rendering to data frames but I think some imperfect code already exists for this
Are you starting from already knowing the key you want to search by e.g. "us-gaap:ScheduleOfInventoryCurrentTableTextBlock"
?
So this was the issue I had. I didn't know initially how to do it. So I queried by the exact name yes
See #652