{ "info": { "author": "Chris O'Connor", "author_email": "cdoconno@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7" ], "description": "# rformat\nSet and row based result filter and formatter\n\n## Overview\nrformat is a nested list proccessor that helps manage:\n * multiple sets or lists\n * ordered output\n * column functions\n * default values\n\nBased on a config, it reformats and returns data in a new structure. rformat can be used as a runtime formatter, with a config being supplied at time of call, or it can be preconfigured, passing along new result sets to the configured rformat object. rformat can be incorporated into a stream processor for pipelining. \n\n## Example\nrformat excels when you have a standard query result format or a denormalized row, but different consumers require custom views. This turns the formatting into a config based operation instead of an explicit release to the underlying data server. \n\nConsider the following data structure you might receive when requesting a report with multiple sections:\n```\nreport = [\n [\n { \"_id\": 123, \"first\": \"Jane\", \"middle\": None, \"last\": \"Smith\"}\n ],\n [\n { \"_id\": 201, \"account_no\": \"2984039756\", \"acct_type\": \"Checking\", \"name\": \"Checking\", \"branch_id\": \"1024309\", \"branch_name\": \"Chase North Clybourn\", \"address\": \"2790 N Clybourn Ave\", \"balance\": 4280.80, \"open_date\": \"20060512T00:00:00Z\" },\n { \"_id\": 202, \"account_no\": \"4528929834\", \"acct_type\": \"Savings\", \"name\": \"Rainy Day\", \"branch_id\": \"3490002\", \"branch_name\": \"Chase Lakeview\", \"address\": \"3215 N Lincoln\", \"balance\": 23802.27, \"opened_on\": \"20030305T00:00:00Z\"}\n ],\n [\n { \"_id\": 10980, \"account_no\": \"2984039756\", \"acct_type\": \"Checking\", \"name\": \"Checking\", \"branch_id\": \"1024309\", \"branch_name\": \"Chase North Clybourn\", \"address\": \"2790 N Clybourn Ave\", \"debit_credit\": \"debit\", \"amt\": 430.30 },\n { \"_id\": 10981, \"account_no\": \"4528929834\", \"acct_type\": \"Savings\", \"name\": \"Rainy Day Fund\", \"branch_id\": \"3490002\", \"branch_name\": \"Chase Lakeview\", \"address\": \"3215 N Lincoln\", \"debit_credit\": \"credit\", \"amt\": 1250.00 },\n { \"_id\": 10982, \"account_no\": \"2984039756\", \"acct_type\": \"Checking\", \"name\": \"Checking\", \"branch_id\": \"1024309\", \"branch_name\": \"Chase North Clybourn\", \"address\": \"2790 N Clybourn Ave\", \"debit_credit\": \"debit\", \"amt\": 102.12 },\n { \"_id\": 10984, \"account_no\": \"2984039756\", \"acct_type\": \"Checking\", \"name\": \"Checking\", \"branch_id\": \"1024309\", \"branch_name\": \"Chase North Clybourn\", \"address\": \"2790 N Clybourn Ave\", \"debit_credit\": \"debit\", \"amt\": 17.65 }\n ]\n]\n```\nUsing the rformat config below, we show only the fields we care about, and reorder compared to our config\n```\nset0:\n 0: \n col: first\n alias: first_name\n 1:\n col: last\n alias: last_name\nset1:\n 0:\n col: acct_type\n alias: type\n format: \n - type: string\n func: upper\n - type: string\n func: format\n tmpl: \"{0} Account\"\n 1:\n col: account\n alias: name \n 2:\n col: account_number\n alias: account_no \n 3: \n col: opened_on\n alias: opened\n formats:\n - type: date\n from: \"%Y%m%dT%H%M%SZ\" \n to: \"%Y-%m-%d\"\nset3:\n 0:\n col: _id\n alias: transaction_id\n 1:\n col: account_no\n alias: account_number\n 2:\n col: debit_credit\n format:\n - type: mapping\n maps: \n from: \"credit\", to: \"CREDIT (+)\"\n from: \"debit\", to: \"DEBIT (-)\"\n 3: \n alias: amount\n col: amt \n```\nAnd then data is returned in the following structure, which can be passed directly to whatever is responsible for writing the data. \n```\n[\n [\n { \"first_name\": \"Jane\", \"last_name\": \"Smith\"}\n ],\n [ \n { type\": \"CHECKING Account\", \"account\": \"Checking\", \"account_number\": \"2984039756\", \"opened\": \"2006-05-12\"},\n { type\": \"SAVINGS Account\", \"account\": \"Rainy Day\", \"account_number\": \"4528929834\", \"opened\": \"2003-03-05\"}\n ],\n [\n { \"transaction_id\": 10980, \"account_number\": \"2984039756\", \"debit_credit\": \"DEBIT (-)\", \"amount\": 430.30 },\n { \"transaction_id\": 10981, \"account_number\": \"4528929834\", \"debit_credit\": \"CREDIT (+)\", \"amount\": 1250.00 },\n { \"transaction_id\": 10982, \"account_number\": \"2984039756\", \"debit_credit\": \"DEBIT (-)\", \"amount\": 102.12 },\n { \"transaction_id\": 10984, \"account_number\": \"2984039756\", \"debit_credit\": \"DEBIT (-)\", \"amount\": 17.65 }\n ]\n]\n```\nThe ordermap config uses integer and float keys for ordering.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://www.qsonlabs.com", "keywords": "", "license": "Apache", "maintainer": "", "maintainer_email": "", "name": "rsformat", "package_url": "https://pypi.org/project/rsformat/", "platform": "", "project_url": "https://pypi.org/project/rsformat/", "project_urls": { "Homepage": "https://www.qsonlabs.com" }, "release_url": "https://pypi.org/project/rsformat/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Record set formatter", "version": "0.0.1" }, "last_serial": 4804245, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "dde888f23d68ee52e2283cde5bde5877", "sha256": "8cc77ecc59190263819518b75cd5a75930db069460db23508369bf22b4d8c770" }, "downloads": -1, "filename": "rsformat-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "dde888f23d68ee52e2283cde5bde5877", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6776, "upload_time": "2019-02-11T05:22:38", "url": "https://files.pythonhosted.org/packages/42/91/eb6f259840fc22e24e3cb2c62b8215ed3bda82750c5ba438edc7c3744543/rsformat-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2c450769decdcaa1e596128684bf251f", "sha256": "7bdf8eceb0f4e1fb34ee1a2205689ba064bd682a43d23bb881db7792425bc07a" }, "downloads": -1, "filename": "rsformat-0.0.1.tar.gz", "has_sig": false, "md5_digest": "2c450769decdcaa1e596128684bf251f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6101, "upload_time": "2019-02-11T05:22:40", "url": "https://files.pythonhosted.org/packages/f4/da/a1032cc0566b2baeb4379a54f1c704606a7497d6c55b46a98879a68fce78/rsformat-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dde888f23d68ee52e2283cde5bde5877", "sha256": "8cc77ecc59190263819518b75cd5a75930db069460db23508369bf22b4d8c770" }, "downloads": -1, "filename": "rsformat-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "dde888f23d68ee52e2283cde5bde5877", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6776, "upload_time": "2019-02-11T05:22:38", "url": "https://files.pythonhosted.org/packages/42/91/eb6f259840fc22e24e3cb2c62b8215ed3bda82750c5ba438edc7c3744543/rsformat-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2c450769decdcaa1e596128684bf251f", "sha256": "7bdf8eceb0f4e1fb34ee1a2205689ba064bd682a43d23bb881db7792425bc07a" }, "downloads": -1, "filename": "rsformat-0.0.1.tar.gz", "has_sig": false, "md5_digest": "2c450769decdcaa1e596128684bf251f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6101, "upload_time": "2019-02-11T05:22:40", "url": "https://files.pythonhosted.org/packages/f4/da/a1032cc0566b2baeb4379a54f1c704606a7497d6c55b46a98879a68fce78/rsformat-0.0.1.tar.gz" } ] }