Skip to main content

A Wireshark-like display filter for dictionaries.

Project description

python_dict_display_filter Logo

Python Dictionary Display Filter

made-with-python PyPI GitHub Build Status Coverage


A Wireshark-like display filter for Python dictionaries and various other data sources, including objects, lists, and SQL databases.

Table of Contents

  1. Quick Start
  2. Features
  3. Examples
  4. Acknowledgements

Quick Start

To quickly get started with the python-dictionary-display-filter, follow the steps below:

Installation

First, install the package using pip:

pip3 install python-dict-display-filter

Initialization

Next, import the necessary module and initialize the DictDisplayFilter with a list of dictionaries:

from pydictdisplayfilter import DictDisplayFilter

actors = [
    {"name": ["Laurence", "Fishburne"], "age": {"born": "1961"}, "gender": "male"},
    {"name": ["Keanu", "Reeves"], "age": {"born": "1964"}, "gender": "male", "power": ["flight", "bullet-time"]},
    {"name": ["Joe", "Pantoliano"], "age": {"born": "1951"}, "gender": "male"},
    {"name": ["Carrie-Anne", "Moss"], "age": {"born": "1967"}, "gender": "female"}
]

ddf = DictDisplayFilter(actors)

Filtering Data

Once the DictDisplayFilter is initialized, you can start filtering the data using the display filter query language. For example, let's filter the actors whose birth year is after 1960:

filter_query = "age.born > 1960"
filtered_data = ddf.filter(filter_query)
print(list(filtered_data))
[
    {"name": ["Laurence", "Fishburne"], "age": {"born": "1961"}, "gender": "male"},
    {"name": ["Keanu", "Reeves"], "age": {"born": "1964"}, "gender": "male", "power": ["flight", "bullet-time"]},
    {"name": ["Carrie-Anne", "Moss"], "age": {"born": "1967"}, "gender": "female"}
]

You can also use more complex queries to filter the data. For example, let's filter male actors born between 1960 and 1964 whose names end with "e":

filter_query = "gender == male and (age.born > 1960 and age.born < 1965) and name matches .*e$"
filtered_data = ddf.filter(filter_query)
print(list(filtered_data))

This will output the filtered data:

[{'name': ['Laurence', 'Fishburne'], 'age': {'born': '1961'}, 'gender': 'male'}]

For more details and advanced usage, please refer to the User Guide.

Features

Python Dictionary Display Filter supports a wide range of features, including:

  • Comparison Operators: ==, !=, <=, <, >=, >, ~=, ~, &
  • Combining Operators: and, or, xor, not
  • Membership Operators: in
  • Types: Text, Number, Date & Time, Ethernet-, IPv4-, IPv6-Address
  • Slicing: Text, Ethernet-, IPv4-, IPv6-Address
  • Functions: upper, lower, len
  • Data Sources: CSV, Dictionaries, JSON, Objects, SQLite

For a detailed description of the individual features check out the User Guide.

Examples

For detailed examples of how the display filter can be utilized, please refer to the following sections of the User Guide:

Acknowledgements

This project wouldn't be possible without these awesome projects:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-dict-display-filter-1.2.0.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_dict_display_filter-1.2.0-py3-none-any.whl (54.8 kB view details)

Uploaded Python 3

File details

Details for the file python-dict-display-filter-1.2.0.tar.gz.

File metadata

  • Download URL: python-dict-display-filter-1.2.0.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.65.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for python-dict-display-filter-1.2.0.tar.gz
Algorithm Hash digest
SHA256 c22d7d96e098668707d92df3c70d61f82b2653624f5045570ebd3fa04f3f5635
MD5 f34bc3bb5a13e9e98e577467ba89d15a
BLAKE2b-256 087a51aa1f1bbca06379de0ecb40cb01b62e82182200e273eda4b354d16dc37b

See more details on using hashes here.

File details

Details for the file python_dict_display_filter-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: python_dict_display_filter-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 54.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.65.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for python_dict_display_filter-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35a88bb1ff68486b74517c3dc1da60ab8a3cfac3ae55906fa72f8b9082018fdb
MD5 6befe07234b65091f9b4d9f32e2424f5
BLAKE2b-256 ca2024cf677a51846faa8e06a3cd6dd7430582446bed45fe143e0ca68be33f0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page