Python Script for Parsing Payments File.
Project description
Payment Parser
Parses a payment file, with multiple blocks of data, into individual CSVs.
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
python3 -m pip install payment-parser
Example CLI Usage:
python3 -m 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 rows 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
Example Code Usage
# from payment_parser.__main__ import parse_doc
from payment_parser import parse_doc
file = 'payment_parser/T140_sample.txt'
output_dir = "payment_parser/output/"
verbose = True
split_term = "MASTERCARD WORLDWIDE"
parse_doc(file, output_dir, split_term, verbose)
Project details
Release history Release notifications | RSS feed
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.1.0.tar.gz
(14.2 kB
view hashes)
Built Distribution
Close
Hashes for payment_parser-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db2245eeb0c3c8d3e6f4789cc35938fe1042b6982f48ff6de2e81206092b9248 |
|
MD5 | 5e4b57eae9aa28d5c087724f606e251d |
|
BLAKE2b-256 | 0512e8754aeb4b107aa7ad8241860f18e78f005e7e14398a80d6a4fef5016a63 |