我正在尝试使用model.filefield模块在Django中访问csv来解析Python中的CSV文件。它可以在Windows上运行,但在Mac上可以达到以下目的:

Exception Type: Error

Exception Value: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?

这是代码:
myfile = customerbulk.objects.all()[0].fileup

mydata = csv.reader(myfile)
    for email,mobile,name,civilid in mydata:
        print email,mobile,name,civilid

最佳答案

我终于找到了解决方案:

mypath = customerbulk.objects.get(pk=1).fileup.path
o = open(mypath,'rU')
mydata = csv.reader(o)

10-05 20:49
查看更多