我有一个 csv 文件,它有大约 900000 行和 13 列,一切正常,直到 28445 行,但之后它给出了错误
编程错误
异常值:格式字符串的参数不足
我试图通过打印行来检查列中是否有问题,但那里似乎没有任何问题。
['INDIA', '5', '1ST TIME MOTHER', 'PATNA', 'A2', 'BRAND DRIVERS', '', '', '很难找到', '', '', '1' , '0 到 12 个月']
def upload(request):
if request.method == 'POST':
cursor = connection.cursor()
query = ''' INSERT INTO johnson_jnjusage (country,no_of_people_house,nursing_cnt,city,sec,bucket,category1,category2, final_category, responders, usageFrequency, base, child_age_group)
VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) '''
x=[]
reader = csv.reader(request.FILES['csvData'],delimiter=',')
i = 0
for row in reader:
x.append(tuple(row))
if i>=5000:
cursor.executemany(query,tuple(x))
transaction.commit()
x=[]
i=0
i = i+1
cursor.close()
return HttpResponse( docfile.name + "'s data inserted into database successfully")
如果你们能帮助我提前谢谢