Make data merging Pythonic
joiner is a tiny library for merging groups of data in a sql-join-like way.
Example
Here is a quick example to get a feeling of joiner.
def test():
hobbys = [
{'first_name': 'A', 'last_name': 'yao', 'hobby': 'pingpong'},
{'first_name': 'A', 'last_name': 'bob', 'hobby': 'shopping'},
{'first_name': 'B', 'last_name': 'bob', 'hobby': 'shopping'},
]
ages = [
{'first_name': 'A', 'last_name': 'yao', 'age': 18},
{'first_name': 'A', 'last_name': 'bob', 'age': 20},
]
heights = [
{'first_name': 'A', 'last_name': 'yao', 'height': 170},
]
hobbys = Group(hobbys)
ages = Group(ages, cols=Cols('age', age='how old'))
heights = Group(heights, cols=Cols('height'))
results = selectfrom(hobbys).leftjoin(ages).on(hobbys.first_name == ages.first_name, hobbys.last_name == ages.last_name)\
.leftjoin(heights).on(hobbys.first_name == heights.first_name, hobbys.last_name == heights.last_name)\
.get()
for result in results:
print(result)
test()
"""
{'first_name': 'A', 'last_name': 'yao', 'age': 18, 'how old': 18, 'height': 170, 'hobby': 'pingpong'}
{'first_name': 'A', 'last_name': 'bob', 'age': 20, 'how old': 20, 'height': None, 'hobby': 'shopping'}
{'first_name': 'B', 'last_name': 'bob', 'age': None, 'how old': None, 'height': None, 'hobby': 'shopping'}
"""
Installation
Use pip <http://pip-installer.org> or easy_install::
pip install joiner-python
Alternatively, you can just drop joiner.py file into your project—it is
self-contained.
Release files for joiner-python 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| joiner-python-0.1.1.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| joiner_python-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / joiner-python-0.1.1.tar.gz
| Download URL | joiner-python-0.1.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d810eaadc2868bdbede65493d5e3edd972491c397c1139e2cb5106072033d2a4
|
|
BLAKE2b-256 checksum How to use checksums |
d1be7759b3b4e185916bcdcc4d7b5675a3de669d89522e0d2af5be3eced7b073
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.0
|
Release files / joiner_python-0.1.1-py3-none-any.whl
| Download URL | joiner_python-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6a7c06a2cbc2c9bc1df7e4593665b640ab75a7f9b39e0a31c02136e359dc3e9
|
|
BLAKE2b-256 checksum How to use checksums |
dcfd28cc81314442ee5ba2602d0a4f6380240f28d1e18e7ef3cb3b471ebb77a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.0
|