Skip to content

Commit

Permalink
#8 Adds documentation regarding usage of ListDisplayFilter, ObjectDis…
Browse files Browse the repository at this point in the history
…playFilter, SQLDisplayFilter
  • Loading branch information
bytebutcher committed Jul 7, 2023
1 parent 92b429b commit 8c63388
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ actors = [
df = ObjectDisplayFilter(actors)
```

Note, that ```pydfql``` supports various other data sources like
<a href="https://github.com/bytebutcher/pydfql/blob/main/docs/USER_GUIDE.md#32-dictdisplayfilter">Python dictionaries</a>,
<a href="https://github.com/bytebutcher/pydfql/blob/main/docs/USER_GUIDE.md#33-listdisplayfilter">lists</a> and
<a href="https://github.com/bytebutcher/pydfql/blob/main/docs/USER_GUIDE.md#34-sqldisplayfilter">SQL databases</a>.

### Filtering Data
Once the display filter is initialized, you can start filtering the data using the
<a href="https://github.com/bytebutcher/pydfql/blob/main/docs/USER_GUIDE.md#4-query-language">display filter query language</a>.
Expand Down Expand Up @@ -90,7 +95,7 @@ This will output the filtered data:
```

Overall, PyDFQL supports a wide range of features, including:
* **Data Sources**: ```Dictionaries```, ```Lists```, ```Objects```, ```SQL```
* **Data Sources**: ```Dictionaries```, ```Lists```, ```Objects```, ```SQL Databases```
* **Comparison Operators:** ```==```, ```!=```, ```<=```, ```<```, ```>=```, ```>```, ```~=```, ```~```, ```&```
* **Combining Operators:** ```and```, ```or```, ```xor```, ```not```
* **Membership Operators:** ```in```
Expand Down
49 changes: 25 additions & 24 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
2. [Installation](#2-installation)

3. [Usage](#3-usage)

3.1 [DictDisplayFilter](#31-dictdisplayfilter)

3.2 [ListDisplayFilter](#32-objectdisplayfilter)
3.1 [ObjectDisplayFilter](#31-objectdisplayfilter)

3.1 [DictDisplayFilter](#32-dictdisplayfilter)

3.3 [ObjectDisplayFilter](#33-listdisplayfilter)
3.2 [ListDisplayFilter](#33-listdisplayfilter)

3.4 [SQLDisplayFilter](#34-sqldisplayfilter)

Expand Down Expand Up @@ -78,27 +78,8 @@ let's move on to the next section and explore how to quickly get started with it
The ```pydfql``` library provides support for filtering data from various sources.
This section will provide an overview of how ```pydfql``` can be used for different data sources.

### 3.1 DictDisplayFilter
The ```DictDisplayFilter``` allows to filter a list of dictionaries.

**Example:**

```python
from pydfql 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"}
]

filter_query = "age.born > 1960 and age.born < 1965"
filtered_data = DictDisplayFilter(actors).filter(filter_query)
print(list(filtered_data))
```

### 3.2 ObjectDisplayFilter
### 3.1 ObjectDisplayFilter
The ```ObjectDisplayFilter``` enables filtering a list of objects.

**Example:**
Expand All @@ -125,6 +106,26 @@ filtered_data = ObjectDisplayFilter(actors).filter(filter_query)
print(list(filtered_data))
```

### 3.2 DictDisplayFilter
The ```DictDisplayFilter``` allows to filter a list of dictionaries.

**Example:**

```python
from pydfql 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"}
]

filter_query = "age.born > 1960 and age.born < 1965"
filtered_data = DictDisplayFilter(actors).filter(filter_query)
print(list(filtered_data))
```

### 3.3 ListDisplayFilter

The ```ListDisplayFilter``` allows filtering a list of lists.
Expand Down

0 comments on commit 8c63388

Please sign in to comment.