Metadata-Version: 1.1
Name: Flask-CSV
Version: 1.0.0
Summary: Easily render CSVs within any flask application
Home-page: https://github.com/Shir0kamii/Flask-CSV
Author: UNKNOWN
Author-email: shir0kamii@gmail.com
License: UNKNOWN
Download-URL: https://github.com/Shir0kamii/Flask-CSV/tags
Description: #########
        Flask-CSV
        #########
        
        Easily render CSVs within any flask application
        
        How to use ?
        ############
        
        Flask-CSV has a simple hepler method named `send_csv` which allows you to send
        csv files in flask endpoints. It takes an iterable of `dict`, a filename and a
        list of fields. The keys of all `dict` in the iterable must correspond to
        given fields.
        
        It will return a `Response` object with filename set and body containing the
        CSV data.
        
        You will better understand with a short example
        
        .. code-block:: python
        
            @app.route("/")
            def index():
                return send_csv([{"id": 42, "foo": "bar"}, {"id": 91, "foo": "baz"}],
                                "test.csv", ["id", "foo"])
        
        Hitting this endpoint will return::
        
            id,foo
            42,bar
            91,baz
        
        
        Passing additionnal parameters to `send_file`
        #############################################
        
        The remaining arguments of `send_csv` will be passed to `send_file`. For
        example, to disable caching, do the following
        
            send_csv([{"id": 42, "foo": "bar"}, {"id": 91, "foo": "baz"}],
                     "test.csv", ["id", "foo"], cache_timeout=0)
        
        
        Change delimiter
        ################
        
        You can also change the delimiter with the `delimiter` option
        
        .. code-block:: python
        
            send_csv([{"id": 42, "foo": "bar"}, {"id": 91, "foo": "baz"}],
                     "test.csv", ["id", "foo"], delimiter=';')
        
        Will result in::
        
            id;foo
            42;bar
            91;baz
        
        
        Use Marshmallow Schemas
        #######################
        
        You can use `Schema` from marshmallow by passing it as `schema` to `send_csv`.
        If you want to keep only ids and ensure they are integers, you could do
        
        .. code-block:: python
        
            class IdSchema(Schema):
                id = fields.Integer()
        
            send_csv([{"id": 42, "foo": "bar"}, {"id": 91, "foo": "baz"}],
                     "test.csv", ["id", "foo"], schema=IdSchema())
        
        And that would result in this::
        
            id
            42
            91
        
Platform: any
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
