Ways to stream CSV content.
Project description
stream-csv
Installation
pip install stream-csv
Usage
from fastapi import FastAPI
from starlette.responses import StreamingResponse
from stream_csv.stream import stream_data
app = FastAPI()
@app.get("/")
def get_csv():
headers = ["type", "color", "size"]
dict_data = [
{"type": "potato", "color": "blue", "size": 1},
{"type": "banana", "color": "red", "size": 2},
{"type": "potato", "size": 3, "color": "yellow"},
]
return StreamingResponse(
stream_data(dict_data, headers),
media_type="text/csv",
headers={"Content-Disposition": "attachment; filename=data.csv"},
)
License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stream-csv-0.1.1.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for stream_csv-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a2d9c819c43473406d53abba16b529acf13fc071023fcbf64485d7a4fe4839b |
|
MD5 | cb55dfd6f4e523b04fb8de4ba9507009 |
|
BLAKE2b-256 | 2b593ffdff3a071dc2db735cdd7908a90b5c863191c0267ea9188d37fe359d72 |