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.3.tar.gz (8.5 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.3-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymongo_aggregate-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4e2b8885b74e2098abe489ffd7d88985b4c633af8f3d3707f377e5311e09ea5e
MD5 36000eeae258126a87b3ee4222b182df
BLAKE2b-256 f765dc13adf8b3931c27ceb51f4a3379e2f884089ef171e02462323eef157037

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo_aggregate-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 be9c027dfd44f8ca28100443f54ce96108c60a7214871618d109409a91eca0bb
MD5 20ecafae574cb2ad3cec6c0debd3960e
BLAKE2b-256 c1722f53edcc15501b08a58ba1955ba72ada3cdfce9d0510d3a6093400845c60

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