Skip to main content

Python Script for Parsing Payments File.

Project description

Payment Parser

Parses a payment file, with multiple blocks of data, into individual CSVs.

PyPI version CodeFactor Grade GitHub languages GitHub license
GitHub pull requests GitHub issues GitHub contributors
GitHub Release Date GitHub last commit GitHub commit activity
GitHub forks GitHub stars GitHub watchers Twitter Follow

The payments file is

  • Stored in fixed-width format
  • Contains hyphen line for calculating column widths
  • Can be split into blocks of text on a split_term

Installation

pip3 install payment-parser

Example Code Usage:

from payment_parser import parse_doc
parse_doc(
    file="payment_parser/T140_sample.txt", 
    output_dir="payment_parser/output/", 
    split_term="MASTERCARD WORLDWIDE", 
    verbose=True,
)

Example CLI Usage:

payment_parser --file "payment_parser/T140_sample.txt" --output_dir "payment_parser/output/" --verbose=False

CLI Output:

File: payment_parser/T140_sample.txt, Split Term: MASTERCARD WORLDWIDE, Output Dir: payment_parser/output/, Verbose: False
Block: 1/13, Report: 1IP727010-AA, Table type: 1
*****   No data found in block above.
Block: 2/13, Report: 1IP727020-AA, Table type: 2
Block: 3/13, Report: 1IP727020-AA, Table type: 2
Block: 4/13, Report: 1IP727020-AA, Table type: 2
Block: 5/13, Report: 1IP727020-AA, Table type: 2
Block: 6/13, Report: 1IP727020-AA, Table type: 2
Block: 7/13, Report: 1IP727020-AA, Table type: 2
Block: 8/13, Report: 1IP728010-AA, Table type: 4
Block: 9/13, Report: 1IP728010-AA, Table type: 4
Block: 10/13, Report: 1IP728010-AA, Table type: 3
Block: 11/13, Report: 1IP728010-AA, Table type: 3
Block: 12/13, Report: 1IP728010-AA, Table type: 3
Block: 13/13, Report: 1IP728010-AA, Table type: 5

Help/Docs Usage:

payment_parser --help                                                                                     

Help/Docs Output:

usage: payment_parser [-h] [--file FILE] [--output_dir OUTPUT_DIR] [--split_term SPLIT_TERM] [--verbose VERBOSE]

optional arguments:
  -h, --help            show this help message and exit
  --file FILE           The absolute path of the file to parse.
  --output_dir OUTPUT_DIR
                        The absolute folder path for saving the parse results.
  --split_term SPLIT_TERM
                        Word or phrase used to split file into chunks.
  --verbose VERBOSE     Whether to enable extra logging.

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

payment_parser-0.2.3.tar.gz (18.5 kB view hashes)

Uploaded Source

Built Distribution

payment_parser-0.2.3-py3-none-any.whl (18.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page