-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPKG-INFO
More file actions
111 lines (72 loc) · 4.54 KB
/
Copy pathPKG-INFO
File metadata and controls
111 lines (72 loc) · 4.54 KB
1
2
3
4
5
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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Metadata-Version: 1.1
Name: PLOD
Version: 0.1.7
Author: Various
Maintainer: Maker Redux Corporation
Maintainer-email: johnd at makerredux com
Home-page: https://github.com/MakerReduxCorp/PLOD/wiki
Download-url: UNKNOWN
Summary: a simpler and easier way to manipulate lists of dictionaries
License: MIT
Description: PLOD - Brief Introduction
=========================
*PLOD* is a simpler and easier way to manipulate lists of dictionaries. *PLOD* stands for Pythonic Lists of Dictionaries.
Why Lists of Dictionaries? Why PLOD?
------------------------------------
Increasingly, software is passing more complex data stores between machines and between processes. Examples include RESTful XML, JSON/MongoDB, Google protobuf, RabbitMQ, etc.
These data stores can include lists of collections, and each collection can have many attributes/values. In Python, these are often internally represented as a list containing dictionaries. For example, if you needed to represent a list of fruits available for purchase:
::
fruits = [
{"name": "bannana", "color": "yellow", "qty": 9, "sizes": [2, 2.4, 3]},
{"name": "cherry", "qty": 40, "sizes": [3, 2, 9]},
{"name": "lime", "color": "green", "qty": 2, "sizes": [2]},
]
One could, of course, pass such a structure into a SQL database such as MySQL or PostgreSQL for manipulation. But that can be overkill for a small amount of temporary data, especially when the infrastructure requirements are light and response time is critical. In that case, manipulating such a list might make more sense to do in-memory within Python itself.
If it is simple enough, one could do so directly using Python. For example:
::
abundant_fruit = [f for f in fruits if f['qty']>5]
But, if the program you are writing does such manipulations regularly, and those manipulations are somewhat more complex, then PLOD might be worth using. To mimic the previous example, this time with PLOD:
::
from PLOD import PLOD
abundant_fruit = PLOD(fruit).gt('qty',5).returnList()
Or a more complex example:
::
from PLOD import PLOD
my_fruit = PLOD(fruit).sort("color").contains("sizes", [3]).renumber("id", insert=True).returnList()
Here the list is sorted by color (missing colors at the top), filtered to entries with a size 3, and renumbered with a new key called "id".
Installation
------------
Install _PLOD_ using pip:
::
pip install PLOD
How to Use
----------
In general, one simply:
1. Creates an instance of the PLOD class.
2. Chains together methods of the class to manipulate the list.
3. Uses a "return" method to get the results you want.
For example, to sort a list:
::
from PLOD import PLOD
my_list = PLOD(fruits).sort("qty").returnList()
Or, to get a string with comma-separated values with a filter:
::
from PLOD import PLOD
csv = PLOD(fruits).gt('qty', 1).returnCSV(keys=['name', 'sizes'])
For more detailed information, please visit the `Documentation <https://github.com/MakerReduxCorp/PLOD/wiki>`_
and `Library Reference <https://github.com/MakerReduxCorp/PLOD/wiki/Code>`_
Other Resources
===============
* `GitHub Repository <https://github.com/MakerReduxCorp/PLOD>`_
* `PyPI web site <https://pypi.python.org/pypi/PLOD>`_
* `Documentation Wiki <https://github.com/MakerReduxCorp/PLOD/wiki>`_
* `Early Overview Video <http://videocenter1.vtcstream.com/videos/video/3546/embed/?access_token=shr00000035466053201644252204311242298919605)>`_
Keywords: lists dictionaries
Requires: types
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules