clean up imports

This commit is contained in:
Sanj 2012-11-15 15:14:50 +05:30
parent 934fd54009
commit d566fedf4c

View File

@ -31,6 +31,8 @@ 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))
for line in lines:
try: try:
year = int(line[1].replace('"', '')[0:4]) year = int(line[1].replace('"', '')[0:4])
year_error = False year_error = False
@ -38,13 +40,12 @@ def import_csv(path=csv_path):
year = None year = None
year_error = True year_error = True
for line in lines:
d = { d = {
'title': line[0], 'title': line[0].strip(),
'year': year, 'year': year,
'director': line[2], 'director': line[2].replace('"', ''),
'producer': line[3], 'producer': line[3].replace('"', '').strip(),
'language': line[4], 'language': line[4].replace('"', '').strip(),
'year_error': year_error 'year_error': year_error
} }
f = Film(**d) f = Film(**d)