Skip to main content

MongoDB aggregate operations declared for python

Project description

PyMongoAggregate

version: "0.0.1"

example

from re import compile as re_compile

from pymongo_aggregate.operations.stages.match import Match
from pymongo_aggregate.operations.stages.project import Project
from pymongo_aggregate.operations.stages.unwind import Unwind
from pymongo_aggregate.operations.operators.regex_find import RegexFind


pipeline = [
    Match({
        "experiment_name": "experiment2"
    }),
    Project({
        "proxy_id": 1,
        "input_text": 1,
        "capture_country": RegexFind(input_field="$output", pattern=re_compile(r"\*\*Country\*\*\n\s+-\s+(.*)\n"))
    }),
    Unwind(
        path="$capture_country.captures",
        include_array_index="country_index",
        preserve_null_and_empty_arrays=True
    ),
    Match({
        "country_index": 0
    }),
    Project({
        "_id": 0,
        "proxy_id": 1,
        "input_text": 1,
        "output_country": "$capture_country.captures"
    })
]

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

pymongo_aggregate-0.0.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

pymongo_aggregate-0.0.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file pymongo_aggregate-0.0.2.tar.gz.

File metadata

  • Download URL: pymongo_aggregate-0.0.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pymongo_aggregate-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8f2ca0b61b34519f78521322776a2a28395b2ca6b15489027e65133886ca6d0f
MD5 27b30dbcfbfa3c313bd2d69640739a55
BLAKE2b-256 47f3e0b648d8a058a0ffb3e630e25c2b4a1a665309c2477cadd7c69624aa3efd

See more details on using hashes here.

File details

Details for the file pymongo_aggregate-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pymongo_aggregate-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e5a5262a92a2a78e172d35a0b78388fdd5608cd450b3efd04c09cebb3b2e8bc2
MD5 2ec350fd4bfac2a6d6572ae94e0e9906
BLAKE2b-256 60bfba8580d0e1e4e7ac5dcb1d5b7d3f16f9adaac9056d9942219c7acfccc8bb

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