Message271975
The code is actually quite simple, I'll post it over here-
def import_eop(request):
with open('C:/Users/sg/Desktop/projects/drfapi/venv/drf/prices_companies_indices_transpose.csv') as f:
contents = f.readlines()
dates = contents[0]
dates = dates.split(",")
dates = dates[1:]
d = []
for i in range(len(dates)):
d.append(Dates(date=dates[i]))
Dates.objects.bulk_create(d)
companies = []
entry = []
for i in range(1, len(contents)):
csline = contents[i].split(",")
prices = csline[1:len(csline)]
company = csline[0]
prices =[float(x) for x in prices]
entry = (Endday(company=company, eop=prices))
entry.save()
f.close()
print('Saved to database')
return HttpResponse('Ok')
Now as you see, I'm not even handling wsgiref.close() at all. This isn't a django issue since django community themselves pointed me to this direction. Let me know if I can be of any help. |
|
Date |
User |
Action |
Args |
2016-08-04 13:40:26 | SG | set | recipients:
+ SG, pje, kristjan.jonsson, tim.golden, r.david.murray, asvetlov, steve.dower |
2016-08-04 13:40:26 | SG | set | messageid: <1470318026.53.0.481146391497.issue27682@psf.upfronthosting.co.za> |
2016-08-04 13:40:26 | SG | link | issue27682 messages |
2016-08-04 13:40:26 | SG | create | |
|