Skip to main content

File Parser SDK

File Parser SDK is a Python library designed to simplify the parsing of various file formats (eg. TEXT, CSV, EXCEL, ZIP, XML, PDF) with a customizable transforming payloads as required. This SDK offers seamless integration, efficient file handling, and the flexibility to address edge cases with user-defined logic tailored to transforming entries as needed.

Features

  • Multi-format Support: Parse TEXT, CSV, EXCEL, ZIP, XML and PDF files effortlessly from AWS S3.
  • Multi-format Response: Supports multiple type of response as per user's need. For eg.- DATAFRAME, JSON, FILE
  • Password-Proctected Support: Parse password protected files.
  • Customizable Edge Case Handling: Define and apply custom functions to handle specific parsing requirements. There can be multiple edge case to handle while transforming the entries such as sanitise_str_column, convert_amount_as_per_currency, convert_date_format etc.
  • S3 Integration: Supports fetching files directly from AWS S3 buckets based on IAM role.
  • Simple Configuration: Initialize with straightforward configurations, avoiding the need for additional setup files.

Installation

Install the SDK using pip:

pip install file_parser_sdk

Prerequisites

  • Your application should be deployed on AWS EKS to enable the SDK to utilize AWS S3 credentials.
  • Python: >= '3.6'
  • Pandas: '2.0.0'

Getting Started

  • Define Custom Edge Cases: When specific functions are needed during file parsing, the SDK will import edge cases from your project structure as shown below. To implement this, create an edgeCases folder in your project and add a file named user_edge_cases.py. Define your custom functions in this file, and reference them in the edge_case section within the file_config as shown below.
from edgeCases import user_edge_cases
self.edge_cases = user_edge_cases
  • Define the configuration required for file parsing logic and S3 bucket names
    s3_config: {
        upload_bucket: reconciliation-live
        download_bucket: reconciliation-live
    }
    file_config: {
        "file_source_1": {
            "read_from_s3_func":"read_complete_excel_file",
            "parameters_for_read_s3": None,
            "file_dtype":{
                "Order_Number": str,
                "Added On":str,
                "Added By":str
            },
            "columns_mapping": {
                <!-- "Column Name in file": "Column name required in output" -->
                "Transaction Type": "TransactionType",
                "Cust Name": "CustomerName",
                "Cust ID": "CustomerId",
                "Transaction Amount": "Amount",
                "OrderNumber": "TransactionReference",
                "Reference ID": "CustomerReferenceId",
                "Target Date": "TargetDate",
                "TransactionDate": "TransactionDate",
                "FeeAmount": "ServiceCharge",
                "TaxAmount": "ServiceTax",
                "NetAmount": "NetAmount"
            }
            "edge_case": {
                <!-- edge case function name which you have defined in user_edge_case.py : params required for that function
                there can be different type of params. For eg. - dict, list, str -->
                <!-- In this convert_amount_as_per_currency is the edge case function which you want to apply while transforming the entries and "Amount" is the param to this function where you will apply the currency conversion -->
                "convert_amount_as_per_currency": "Amount"
            }
        },
    }
  • Define a ParsedDataResponseType enum
import enum
class ParsedDataResponseType(enum.Enum):
    DATAFRAME="DATAFRAME"
    FILE="FILE"
    JSON="JSON"
  • Import and initialise the file parser
from file_parser_sdk import FileParserSDK

parser = FileParser(config={s3_config: s3_config, file_config: file_config})
parsed_data = parser.parse("s3://your-bucket-name/path/to/your/file.csv", file_source, ParsedDataResponseType.DATAFRAME.value)
//By default SDK will provide response as DATAFRAME

Release files for file-parser-sdk 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for file-parser-sdk 0.3.2
File Size Uploaded
file_parser_sdk-0.3.2.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for file-parser-sdk 0.3.2
File Interpreter ABI Platform
file_parser_sdk-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 30.1 kB

Release files / file_parser_sdk-0.3.2.tar.gz

Download URL file_parser_sdk-0.3.2.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a3331e1a0c682d1988ea59bc7531e0972995134ee64c6e6bec6894935cb6af91
BLAKE2b-256 checksum
How to use checksums
43255f99d5fe85c8e4bcba34ad6880c5aca6c8a6f2184f6948db1060923622d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / file_parser_sdk-0.3.2-py3-none-any.whl

Download URL file_parser_sdk-0.3.2-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7830e78e8b1a5ca6898f02c37935a028dd22511204a82497df620cf6b16b85a
BLAKE2b-256 checksum
How to use checksums
659a77d9d9596c0c6c8e4e0a1b2796f29bbb84767cf699d5d0cf85e07fe2c9d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page