Add option to change row class
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 886
- Forks
- 137
- PR merge metrics
- No merged PRs in 30d
Description
The row class returined by iterating over rows.Table could be a dict a collections.namedtuple or even a customized class representing that data. We need to provide an way to the user to specify this class. Actually, preferably the user should pass a metaclass (think of collections.namedtuple: when you call it the object returned is a Python class).
We may create an interface for it (instead of just passing dict for example, we may need to create a RowDict class that does some things).
Another option: use the attrs library.
Possible API: add row_class parameter to import functions, like in:
for book in rows.import_from_csv(csv_path, row_class=dict):
print(book["title"])
Related to #304.
Note: check if we can integrate this feature with scrapy so it'll easier to parse data using rows in a scrapy project.
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 inspecting rows.Table and the import functions, especially the rows.import_from_csv API, to understand where row objects are created. Define and test the requested row_class behavior for dict, namedtuple-style factories, and custom classes, while checking whether the design can support the Scrapy use case and related issue #304.
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
- Mostly clear
- Newbie friendliness
- 32/100