Add way to query a Table
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 886
- Forks
- 137
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes is really handy to just have a rows.Table filtered (like we would do using Django ORM with the .objects.filter method).
I don't know if the best option for rows API is to add a filter/query method into rows.Table (will return a new rows.Table object) or just create a helper function. In my scripts I'm currently creating helper functions so I can feel better how the API should be.
The implementation would be something like this:
def filter_row(row, kwargs):
for key, value in kwargs.items():
if getattr(row, key) != value:
break
else:
return True
return False
def query_table(table, *args, **kwargs):
new_table = rows.Table(fields=table.fields)
# TODO: should also add _meta and other Table attributes
new_table.extend(row._asdict() for row in table if filter_row(row, kwargs))
return new_table
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the rows.Table implementation and reviewing how Table fields and other attributes are represented. Compare the proposed filter_row and query_table helpers with the existing API, then define the filtering API and metadata-preservation behavior before adding coverage for the chosen behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100