encabezados en el csv

parent 158694de
...@@ -497,35 +497,6 @@ def apiDownloadNews(request): ...@@ -497,35 +497,6 @@ def apiDownloadNews(request):
response = HttpResponse(s.getvalue(), content_type="application/x-zip-compressed") response = HttpResponse(s.getvalue(), content_type="application/x-zip-compressed")
response['Content-Disposition'] = 'attachment; filename="news_' + str(int(time.time())) + '.zip"' response['Content-Disposition'] = 'attachment; filename="news_' + str(int(time.time())) + '.zip"'
return response return response
apiuser = Apikey.objects.get(key=request.GET["key"]).user
if apiuser is None:
return HttpResponse(json.dumps("{}"), content_type="application/json")
else:
request.user=apiuser
news = getNewsByRequest(request)
s = BytesIO()
zf = zipfile.ZipFile(s, "w")
zf.writestr("setting.txt", json.dumps(request.GET))
data = news2JSON(news);
if request.GET['format']=="JSON":
zf.writestr("data.json", json.dumps(data))
if request.GET['format']=="CSV":
csvString = StringIO()
writer = csv.writer(csvString,quoting=csv.QUOTE_ALL)
for d in data:
row = [ d[k] for k in d ]
writer.writerow( row )
zf.writestr("data.csv", csvString.getvalue())
zf.close()
response = HttpResponse(s.getvalue(), content_type="application/x-zip-compressed")
response['Content-Disposition'] = 'attachment; filename="news_'+ str(int(time.time()))+'.zip"'
return response
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def wsWordCloud(request, newsId): def wsWordCloud(request, newsId):
text = News.objects.filter(id=newsId)[0].text text = News.objects.filter(id=newsId)[0].text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment