Skip to main content

Simple command line tool to reconcile datasets

Project description

recon-cli: Simple command line tool to reconcile datasets

What is it

recon-cli is a Python package and cli tool to reconcile datasets against each other using a common field. It aims to be provide a simple interface for reliable reconciliations, removing common logic errors made when performing reconciliations.

Where to get it

The source code is currently hosted on GitHub at: https://github.com/mynhardtburger/recon-cli

Binary installers for the latest released version are available at the Python Package Index (PyPI)

For commandline use install recon-cli via pipx:

# For command line usage
pipx install recon-cli
recon --help

To use it within your own project install via pip:

# PyPI install
pip install recon-cli

Usage

CLI

 Usage: recon [OPTIONS] LEFT RIGHT LEFT_ON RIGHT_ON

╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────╮
│ *    left          FILE  Path to the left dataset. [required]                                        │
│ *    right         FILE  Path to the right dataset. [required]                                       │
│ *    left_on       TEXT  Reconcile using this field from the left dataset. [required]                │
│ *    right_on      TEXT  Reconcile using this field from the right dataset. [required]               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Input options ──────────────────────────────────────────────────────────────────────────────────────╮
│ --left-suffix         TEXT  Suffix to append to the left dataset's column names. [default: _left]    │
│ --right-suffix        TEXT  Suffix to append to the right dataset's column names. [default: _right]  │
│ --left-sheet          TEXT  Sheet to read from left if left is a spreadsheet. [default: Sheet1]      │
│ --right-sheet         TEXT  Sheet to read from left if left is a spreadsheet. [default: Sheet1]      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Output options ─────────────────────────────────────────────────────────────────────────────────────╮
│ --output-file                      TEXT  Path to save results (in xlsx format) to.                   │
│ --std-out        --no-std-out            Print results to stdout. [default: no-std-out]              │
│ --info-only      --no-info-only          Print summary results only. [default: no-info-only]         │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯

Python

# Recon import
from recon import Reconcile

# Read from files
recon = Reconcile.read_files(
    left_file="sales_orders.xlsx",
    right_file="deliveries.csv",
    left_on="Document #",
    right_on="Sales Order #",
    left_kwargs={"sheet_name": "Sales"},
)

# Or read from pandas dataframes
recon = Reconcile.read_df(
    left_df=sales_df,
    right_df=deliveries_df,
    left_on="Document #",
    right_on="Sales Order #",
)

# Properties:
# Components of the recon are lazily evaluated and cached as you access the relevant properties.
# All properties return a pandas DataFrame.
# The original indexes are preserved, except for the .both property where the original indexes are columns.
recon.left  # Original left dataset
recon.right  # Original right dataset

recon.left_only  # Records from left dataset which is not found in the right dataset.
recon.right_only  # Records from right dataset which is not found in the left dataset.

recon.left_duplicate  # Duplicate records in the left dataset. The first record is not listed.
recon.right_duplicate  # Duplicate records in the right dataset. The first record is not listed.

recon.left_both  # Records from left dataset which is also found in the right dataset.
recon.right_both # Records from right dataset which is also found in the left dataset.

recon.both  # Common records. A merger of both datasets
recon.all_data # All records classified. A merger of both datasets

recon.is_left_unique  # bool. Are there duplicate records within the `left_on` field?
recon.is_right_unique  # bool. Are there duplicate records within the `right_on` field?
recon.relationship  # 1:1, 1:m, m:1 or m:m relationship between datasets

# Output methods:
# `recon_components` parameter is an ordered list of any of the DataFrame property names.
# "all" is a shorthand for most properties.
recon.info()  # Prints a summary of recon results
recon.to_stdout(recon_components=["all"]) # Prints all recon results to console
recon.to_xlsx(path="recon_results.xlsx", recon_components=["all"]) # Saves all recon results to xlsx

Dependencies

License

MIT

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

recon_cli-0.0.4.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

recon_cli-0.0.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: recon_cli-0.0.4.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.30.0

File hashes

Hashes for recon_cli-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2dc56d205f0020bec8129333288115af0aa64bf0f96fb854d663c7313254daa6
MD5 c64849cb9f2e0ab696fc01fdcc08f3c6
BLAKE2b-256 927ac641cdde71d5203d88def282fc493103dffa8e80713b3755484bd96e1ca5

See more details on using hashes here.

File details

Details for the file recon_cli-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: recon_cli-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.30.0

File hashes

Hashes for recon_cli-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a2094cb0f0dd4b1038e2c55df29419e3a55f84f84923cc4c290b9e7f93b78bb0
MD5 d4be7913a34c47f6e788a6269f01e6f0
BLAKE2b-256 5dc60060504c755896df99b5138bc81d13c8fe57503559a80a65a9cc1cdcb639

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