deal with erroneous year entries
This commit is contained in:
parent
d94ccc2812
commit
934fd54009
|
@ -31,13 +31,21 @@ def do(path=path):
|
||||||
|
|
||||||
def import_csv(path=csv_path):
|
def import_csv(path=csv_path):
|
||||||
lines = csv.reader(open(path))
|
lines = csv.reader(open(path))
|
||||||
|
try:
|
||||||
|
year = int(line[1].replace('"', '')[0:4])
|
||||||
|
year_error = False
|
||||||
|
except:
|
||||||
|
year = None
|
||||||
|
year_error = True
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
d = {
|
d = {
|
||||||
'title': line[0],
|
'title': line[0],
|
||||||
'year': int(line[1].replace('"', '')[0:4]),
|
'year': year,
|
||||||
'director': line[2],
|
'director': line[2],
|
||||||
'producer': line[3],
|
'producer': line[3],
|
||||||
'language': line[4]
|
'language': line[4],
|
||||||
|
'year_error': year_error
|
||||||
}
|
}
|
||||||
f = Film(**d)
|
f = Film(**d)
|
||||||
f.save()
|
f.save()
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Film(models.Model):
|
||||||
producer = models.CharField(max_length=512, blank=True)
|
producer = models.CharField(max_length=512, blank=True)
|
||||||
language = models.CharField(max_length=64, blank=True)
|
language = models.CharField(max_length=64, blank=True)
|
||||||
year = models.IntegerField(max_length=4, blank=True, null=True)
|
year = models.IntegerField(max_length=4, blank=True, null=True)
|
||||||
|
year_error = models.BooleanField(default=False)
|
||||||
available = models.BooleanField(default=False)
|
available = models.BooleanField(default=False)
|
||||||
notes = models.TextField(blank=True)
|
notes = models.TextField(blank=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user