# aioxlsxstream
Generate the xlsx file on fly without storing entire file in memory.
Generated excel workbook contain only one sheet. All data writes as strings.
## Installation
```
pip install aioxlsxstream
```
## Requirements
* Python 3.8+
### Simple exapmle
```python
import aioxlsxstream
import asyncio
async def main():
async def rows_generaor():
async def row_cells_generator(row):
for col in range(5):
yield row*5 + col
for row in range(10):
yield row_cells_generator(row)
xlsx_file = aioxlsxstream.XlsxFile()
xlsx_file.write_sheet(rows_generaor())
with open("example.xlsx", "wb") as f:
async for data in xlsx_file:
f.write(data)
asyncio.run(main())
```
### aiohttp Example
```python
from aiohttp import web, hdrs
import aioxlsxstream
async def rows_generaor():
async def row_cells_generator(row):
for col in range(5):
yield row*5 + col
for row in range(10):
yield row_cells_generator(row)
async def handle(request):
filename = "example.xlsx"
response = web.StreamResponse(
status=200,
headers={
hdrs.CONTENT_TYPE: "application/octet-stream",
hdrs.CONTENT_DISPOSITION: (f"attachment; " f'filename="{filename}"; '),
},
)
await response.prepare(request)
xlsx_file = aioxlsxstream.XlsxFile() # or CsvFile("csv") or CsvFile("tsv")
xlsx_file.write_sheet(rows_generaor())
async for data in xlsx_file:
await response.write(data)
return response
app = web.Application()
app.add_routes([web.get('/', handle)])
if __name__ == '__main__':
web.run_app(app)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/lososkin/aioxlsxstream",
"name": "aioxlsxstream",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "async xlsx streaming",
"author": "lososkin",
"author_email": "yalososka@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/67/54/089741cc7a39f37f07ef4251667a89bf5d3edfd88a658978ee2d79381d81/aioxlsxstream-1.0.3.tar.gz",
"platform": null,
"description": "\n# aioxlsxstream\n\nGenerate the xlsx file on fly without storing entire file in memory.\nGenerated excel workbook contain only one sheet. All data writes as strings.\n\n## Installation\n\n```\npip install aioxlsxstream\n```\n\n## Requirements\n\n * Python 3.8+\n\n### Simple exapmle\n\n```python\nimport aioxlsxstream\nimport asyncio\n\nasync def main():\n async def rows_generaor():\n async def row_cells_generator(row):\n for col in range(5):\n yield row*5 + col\n for row in range(10):\n yield row_cells_generator(row)\n\n xlsx_file = aioxlsxstream.XlsxFile()\n xlsx_file.write_sheet(rows_generaor())\n\n with open(\"example.xlsx\", \"wb\") as f:\n async for data in xlsx_file:\n f.write(data)\n\nasyncio.run(main())\n```\n\n### aiohttp Example\n\n```python\nfrom aiohttp import web, hdrs\nimport aioxlsxstream\n\nasync def rows_generaor():\n async def row_cells_generator(row):\n for col in range(5):\n yield row*5 + col\n for row in range(10):\n yield row_cells_generator(row)\n\nasync def handle(request):\n filename = \"example.xlsx\"\n response = web.StreamResponse(\n status=200,\n headers={\n hdrs.CONTENT_TYPE: \"application/octet-stream\",\n hdrs.CONTENT_DISPOSITION: (f\"attachment; \" f'filename=\"{filename}\"; '),\n },\n )\n await response.prepare(request)\n\n xlsx_file = aioxlsxstream.XlsxFile() # or CsvFile(\"csv\") or CsvFile(\"tsv\")\n xlsx_file.write_sheet(rows_generaor())\n\n async for data in xlsx_file:\n await response.write(data)\n return response\n\napp = web.Application()\napp.add_routes([web.get('/', handle)])\n\nif __name__ == '__main__':\n web.run_app(app)\n```\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Asynchronous xlsx files generator",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/lososkin/aioxlsxstream"
},
"split_keywords": [
"async",
"xlsx",
"streaming"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "82ffc65b560b66ca77e59dd42ecaa327f6f8e34c454976d01f656ba8fe301d17",
"md5": "b1566cbd3cfff9933938effefc88734c",
"sha256": "fd65ae92ebfb3d793b57f874fb6f5c6272e2bcbe11d5013280a56136acd7c1a9"
},
"downloads": -1,
"filename": "aioxlsxstream-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b1566cbd3cfff9933938effefc88734c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 22822,
"upload_time": "2023-10-05T22:31:35",
"upload_time_iso_8601": "2023-10-05T22:31:35.667402Z",
"url": "https://files.pythonhosted.org/packages/82/ff/c65b560b66ca77e59dd42ecaa327f6f8e34c454976d01f656ba8fe301d17/aioxlsxstream-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6754089741cc7a39f37f07ef4251667a89bf5d3edfd88a658978ee2d79381d81",
"md5": "0727666e6099b3f99a899fc7bc9823cc",
"sha256": "913fc3987a72739e233216c771a6efadecaddca86f18b59fd02230c09bef3e0f"
},
"downloads": -1,
"filename": "aioxlsxstream-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "0727666e6099b3f99a899fc7bc9823cc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 20602,
"upload_time": "2023-10-05T22:31:37",
"upload_time_iso_8601": "2023-10-05T22:31:37.647459Z",
"url": "https://files.pythonhosted.org/packages/67/54/089741cc7a39f37f07ef4251667a89bf5d3edfd88a658978ee2d79381d81/aioxlsxstream-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-05 22:31:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lososkin",
"github_project": "aioxlsxstream",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aioxlsxstream"
}