{ "info": { "author": "", "author_email": "shir0kamii@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "#########\nFlask-CSV\n#########\n\nEasily render CSVs within any flask application\n\nInstall\n#######\n\nFlask-CSV is packaged and you can use pip to install it::\n\n pip install flask_csv\n\n\nHow to use ?\n############\n\nFlask-CSV has a simple hepler method named `send_csv` which allows you to send\ncsv files in flask endpoints. It takes an iterable of `dict`, a filename and a\nlist of fields. The keys of all `dict` in the iterable must correspond to\ngiven fields.\n\nIt will return a `Response` object with filename set and body containing the\nCSV data.\n\nYou will better understand with a short example.\n\n.. code-block:: python\n\n @app.route(\"/\")\n def index():\n return send_csv([{\"id\": 42, \"foo\": \"bar\"}, {\"id\": 91, \"foo\": \"baz\"}],\n \"test.csv\", [\"id\", \"foo\"])\n\nHitting this endpoint will return::\n\n id,foo\n 42,bar\n 91,baz\n\n\nPassing additionnal parameters\n##############################\n\nThe remaining arguments of `send_csv` will be passed to `send_file`. For\nexample, to disable caching, do the following:\n\n.. code-block:: python\n\n send_csv([{\"id\": 42, \"foo\": \"bar\"}, {\"id\": 91, \"foo\": \"baz\"}],\n \"test.csv\", [\"id\", \"foo\"], cache_timeout=0)\n\nYou can also pass additionnal parameters to the CSV writer like this:\n\n.. code-block:: python\n\n send_csv([{\"foo\": 42}, {\"bar\": \"baz\"}], \"test.csv\", [\"foo\"],\n writer_kwargs={\"extrasaction\": \"ignore\"})\n\nIn this example, the \"bar\" key will not raise a `ValueError` since the writer\nwill be given the parameter `extrasaction` with the value \"ignore\".\n\n\nChange delimiter\n################\n\nYou can also change the delimiter with the `delimiter` option.\n\n.. code-block:: python\n\n send_csv([{\"id\": 42, \"foo\": \"bar\"}, {\"id\": 91, \"foo\": \"baz\"}],\n \"test.csv\", [\"id\", \"foo\"], delimiter=';')\n\nWill result in::\n\n id;foo\n 42;bar\n 91;baz\n\nSpecifying file encoding\n########################\n\nYou can also specify the encoding used to send the file, with the `encoding` option (`utf-8` by default).\n\n.. code-block:: python\n\n send_csv([{\"id\": 42, \"foo\": \"bar\"}, {\"id\": 91, \"foo\": \"baz\"}],\n \"test.csv\", [\"id\", \"foo\"], encoding='iso-8859-1')\n\nUse Marshmallow Schemas\n#######################\n\nYou can use `Schema` from marshmallow by passing it as `schema` to `send_csv`.\nIf you want to keep only ids and ensure they are integers, you could do:\n\n.. code-block:: python\n\n class IdSchema(Schema):\n id = fields.Integer()\n\n send_csv([{\"id\": 42, \"foo\": \"bar\"}, {\"id\": 91, \"foo\": \"baz\"}],\n \"test.csv\", [\"id\", \"foo\"], schema=IdSchema())\n\nAnd that would result in this::\n\n id\n 42\n 91\n\nSystemError returned a result with an error set\n###############################################\n\nWhen using uwsgi for your flask app, it might raise this kind of error on the send_file method.\nIf that were the case, adding the following option to your uwsgi conf should solve it :\n\n`wsgi-disable-file-wrapper = true`\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/Shir0kamii/Flask-CSV/tags", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Shir0kamii/Flask-CSV", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "Flask-CSV", "package_url": "https://pypi.org/project/Flask-CSV/", "platform": "any", "project_url": "https://pypi.org/project/Flask-CSV/", "project_urls": { "Download": "https://github.com/Shir0kamii/Flask-CSV/tags", "Homepage": "https://github.com/Shir0kamii/Flask-CSV" }, "release_url": "https://pypi.org/project/Flask-CSV/1.2.0/", "requires_dist": null, "requires_python": "", "summary": "Easily render CSVs within any flask application", "version": "1.2.0" }, "last_serial": 4559873, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "b4638505c68482c5d2540852b4b3fed7", "sha256": "984a0861c9078c4a88a03b1940deea9e48fb4cdf268cda5d3f117aa962adca90" }, "downloads": -1, "filename": "Flask-CSV-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b4638505c68482c5d2540852b4b3fed7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1033, "upload_time": "2017-05-03T19:29:16", "url": "https://files.pythonhosted.org/packages/0a/90/f3b4798496b9c68cff7bd99a479c7a680ce23644d55d573fffa6122ab79d/Flask-CSV-0.1.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "20d4d18ffacace1476962eff3f1897fd", "sha256": "fcb26a87ac4d6c798ee159e67ce549428429cf3894502a9ef5ee44ed625b2481" }, "downloads": -1, "filename": "Flask-CSV-0.3.0.tar.gz", "has_sig": false, "md5_digest": "20d4d18ffacace1476962eff3f1897fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1476, "upload_time": "2017-05-04T00:03:34", "url": "https://files.pythonhosted.org/packages/39/ec/6a141354e8cc2d740f4a7d1c3003908191e6faf1ea03d07183d3bf4d4c44/Flask-CSV-0.3.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "be90321ea73c663d646f4eb7f1f01ab8", "sha256": "d0f52fc7d1b7601647c14db9104285a1cdbbd3a3ad16efd2f792773755af8637" }, "downloads": -1, "filename": "Flask-CSV-1.0.0.tar.gz", "has_sig": false, "md5_digest": "be90321ea73c663d646f4eb7f1f01ab8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2339, "upload_time": "2017-05-04T00:25:24", "url": "https://files.pythonhosted.org/packages/e9/a8/8cef9e4adea04da4ced116cc3c2b3e87b96bc8ceff30e33d049ee3ebc965/Flask-CSV-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "0eed26e208a25fc5246db6b1396b19a4", "sha256": "fa2d1c85246369d7fbd436f3c5d76260a7d1f421799e261bd33ba664624bc318" }, "downloads": -1, "filename": "Flask-CSV-1.0.1.tar.gz", "has_sig": false, "md5_digest": "0eed26e208a25fc5246db6b1396b19a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2446, "upload_time": "2017-05-04T00:30:36", "url": "https://files.pythonhosted.org/packages/42/0a/e939e31e24ac0f80b5b06b67bb066d97e9cb038dead0b0742b2fa2195cfa/Flask-CSV-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "9574c02418af557b1c93fc713566027e", "sha256": "f1315c89a7efa7e842353d12796c2fdd40ee6639f8a69fb131b7e285928fa23e" }, "downloads": -1, "filename": "Flask-CSV-1.1.0.tar.gz", "has_sig": false, "md5_digest": "9574c02418af557b1c93fc713566027e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2496, "upload_time": "2018-02-02T09:01:12", "url": "https://files.pythonhosted.org/packages/5e/cf/54b05de9161eb8a7e50ecd8e7b53cf4a9e1112d795b5e7b4150d55d8883f/Flask-CSV-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "a7b3d6c6031d0897dcb223465b33568f", "sha256": "b8642cd9b21b316f51fd5d8ed413b53526c80f5a89ff7024ede8b12e10b8c68d" }, "downloads": -1, "filename": "Flask-CSV-1.2.0.tar.gz", "has_sig": false, "md5_digest": "a7b3d6c6031d0897dcb223465b33568f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2897, "upload_time": "2018-12-04T14:42:17", "url": "https://files.pythonhosted.org/packages/27/c8/e822673a0e5add39315eba04a28c84301aa5dedd99e834c3319fe212c09c/Flask-CSV-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a7b3d6c6031d0897dcb223465b33568f", "sha256": "b8642cd9b21b316f51fd5d8ed413b53526c80f5a89ff7024ede8b12e10b8c68d" }, "downloads": -1, "filename": "Flask-CSV-1.2.0.tar.gz", "has_sig": false, "md5_digest": "a7b3d6c6031d0897dcb223465b33568f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2897, "upload_time": "2018-12-04T14:42:17", "url": "https://files.pythonhosted.org/packages/27/c8/e822673a0e5add39315eba04a28c84301aa5dedd99e834c3319fe212c09c/Flask-CSV-1.2.0.tar.gz" } ] }