我正在使用在这里找到的最新 Django Csv Importer:http: //django-csv-importer.readthedocs.org/en/latest/index.html
包含整数的 CSV 的第 2 行没有任何空行。都是数字。我进入 CSV 并将所有带有数字的行转换为整数,然后重新上传文件,但我仍然收到此错误:
line 182, in import_data
return importer.import_data(data)
File "/.../lib/python2.7/csvImporter/model.py", line 282, in import_data self.process_line(data, line, lines, line_number)
File "/.../lib/python2.7/csvImporter/model.py", line 299, in process_line
raise CsvDataException(line_number, field_error = e.message)
CsvDataException: Line 2: invalid literal for int() with base 10: ''
我的模型设置如下:
class Character(models.Model):
name = models.CharField(max_length=128)
points = models.IntegerField()
description = models.TextField()
image = models.ManyToManyField(Image)
dice = models.IntegerField(blank=True, null=True)
def __unicode__(self):
return self.name
class CsvCharacterUpload(CsvDbModel):
name = models.CharField(max_length=128)
points = models.IntegerField()
description = models.TextField()
image = models.ManyToManyField(Image)
dice = models.IntegerField(blank=True, null=True)
class Meta:
dbModel = Character
delimiter = ","
has_header = True