Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

csv download django

import csv
from django.http import HttpResponse

def some_view(request):
    # Create the HttpResponse object with the appropriate CSV header.
    response = HttpResponse(
        content_type='text/csv',
        headers={'Content-Disposition': 'attachment; filename="somefilename.csv"'},
    )

    writer = csv.writer(response)
    writer.writerow(['First row', 'Foo', 'Bar', 'Baz'])
    writer.writerow(['Second row', 'A', 'B', 'C', '"Testing"', "Here's a quote"])

    return response
Comment

PREVIOUS NEXT
Code Example
Python :: message handler python telegram bot example 
Python :: tensorflow metrics accuracy 
Python :: Class In Python With Instance Method 
Python :: python undefined 
Python :: write image out opencv 
Python :: how to read linux environment variable in python 
Python :: python extract email attachment 
Python :: python json write utf 8 
Python :: python sort multiple keys 
Python :: flask recive list 
Python :: python dict copy() 
Python :: Change Python interpreter in pycharm 
Python :: arrayfield in django 
Python :: how to make tkinter look modern 
Python :: check if an object has an attribute in Python 
Python :: selenium save page as image 
Python :: python __repr__ 
Python :: pandas read csv dtype list 
Python :: django validators import 
Python :: check multiple keys in python dict 
Python :: Python Tkinter PanedWindow Widget 
Python :: lists to dictionary python 
Python :: chrome webdrivermanager 
Python :: upload file to aws 
Python :: colorgram in python 
Python :: download images off unsplash python 
Python :: python while 
Python :: netcdf in python 
Python :: add horizontal line to plotly scatter 
Python :: how to read json from python 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =