Re: export .csv file from database

2013-07-19 Thread Peter of the Norse
Two things: First, Ms Excel sucks. From that attached screenshot it's obvious that it thought it was a space separated file. When actually using MS Office, I recommend that you add `quoting=csv.QUOTE_ALL` to all csv writers. Second, the HttpResponse object is file-like. You don't need to jump

Re: export .csv file from database

2013-06-19 Thread Radomir Wojcik
> > this might come of use, it exports any query set to csv. I use it a lot: > > def queryset_export_csv(qs): import csv #from django.db.models.loading import get_model response = HttpResponse(mimetype='text/csv') # force download. response['Content-Disposition'] = 'attachmen

Re: export .csv file from database

2013-06-19 Thread Vernon D. Cole
I am guessing that your csv writer is outputting something that your spreadsheet is reading incorrectly. Try opening the csv with a text editer (a good one, like Notepad++) so that you can really see what is going on. Embedded commas or quotes inside a field are invitations for disaster, and

Re: export .csv file from database

2013-06-19 Thread Derek
>From just a quick glance, I have probably missed complex here - but one option to try is changing the delimiter from a comma to another character (e.g. a semi-colon) - see: http://docs.python.org/2/library/csv.html#dialects-and-formatting-parameters (But its also possible that in all the encodin

export .csv file from database

2013-06-17 Thread roopasingh250
views.py @login_requireddef export_csv(request): user = request.user # heading columns headerrow = ['Filename', 'Description','Notes other','Reporter Name'] allrows = [] today = datetime.datetime.today() # default to show today reports = Report.objects.filter(user=user)