我正在尝试导入csv文件,尝试清理内容,并确保消除所有错误。
IO错误
文件格式错误
数据错误。
我正在使用下面的代码段,有人可以帮我清理并使其更加pythonic吗?
try:
fl = request.FILES['csv']
except:
return HttpResponse("Some IO Error")
try:
reader = csv.reader(fl)
except:
return HttpResponse("File Not Supported")
reader.next() # this makes sure the heading is
cleaned_csv_content = list()
for row in reader:
err = 0
fname, lname, e_mail = row
try:
validate_email(email)
except:
pass
err = 1
if not err:
cleaned_csv_content.append(fname, lname, e_mail)
谢谢!