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.4.tar.gz (8.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pymongo_aggregate-0.0.4.tar.gz
  • Upload date:
  • Size: 8.5 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.4.tar.gz
Algorithm Hash digest
SHA256 6f01f00896c212bb79e7d0e2bfc44536224871536234119b41d9389c3b8cf11b
MD5 1f6209e65f66adadd7a604e92d547dce
BLAKE2b-256 65bbda30fa962deba870c12c43dd8a281fb3c868535195e9885093004bd375fe

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