Sushant added the comment: 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. ---------- nosy: +SG _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27682> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com