Skip to main content

Ways to stream CSV content.

Project description

stream-csv

Latest Commit
Package version

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


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)

Uploaded Source

Built Distribution

stream_csv-0.1.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

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