Skip to main content

File Genie is designed to parse various file types and transform them according to provided configuration

Project description

FileGenie SDK

FileGenie 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_genie

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 genie
from file_genie import FileGenie

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

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

file_genie-0.0.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

file_genie-0.0.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file file_genie-0.0.1.tar.gz.

File metadata

  • Download URL: file_genie-0.0.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for file_genie-0.0.1.tar.gz
Algorithm Hash digest
SHA256 465374d880e1a0e1591833fedd706475ecf561047f6307f71ed7208c12af33b9
MD5 9e8ea7fe30d2a0373b7e1ebd33cdd384
BLAKE2b-256 aeca349108836ff1fdeae104febadbe41c837cbbacfb1129f7a72c4d525a66bf

See more details on using hashes here.

File details

Details for the file file_genie-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: file_genie-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for file_genie-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a0302523d6a69804ebe542de609a337952eeaaa479c4dfb6af6397d440333b5
MD5 1fcb123725e842959faaf70f3ef52668
BLAKE2b-256 3a526d67ee5e9f8edd54625fca6ca5790af5151248fb791232c25122536dd149

See more details on using hashes here.

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