fix csv reading
This commit is contained in:
parent
b9a4ee9530
commit
d3e575dd93
|
@ -1,5 +1,6 @@
|
|||
from collections import Counter
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
import csv
|
||||
import functools
|
||||
|
||||
from imdb_utils import IMDbUtils
|
||||
|
@ -28,15 +29,17 @@ def get_vcinema_viewings(token_id, token_secret, viewings_csv=None, combine_repe
|
|||
viewings_csv_rows = viewings_csv.strip().split("\n")
|
||||
|
||||
headers = viewings_csv_rows.pop(0).split(",")
|
||||
viewings = [dict(zip(headers, row.split(","))) for row in viewings_csv_rows]
|
||||
|
||||
for viewing in viewings:
|
||||
viewing['viewings'] = [{'date_watched': viewing['date_watched'], 'season': viewing['season'], 'rating': viewing['rating']}]
|
||||
viewing.pop('date_watched')
|
||||
viewing.pop('season')
|
||||
viewing.pop('rating')
|
||||
csvreader = csv.reader(viewings_csv_rows, delimiter=',', quotechar='"')
|
||||
viewings = [dict(zip(headers, list(row))) for row in csvreader]
|
||||
|
||||
if combine_repeat_viewings:
|
||||
for viewing in viewings:
|
||||
viewing['viewings'] = [
|
||||
{'date_watched': viewing['date_watched'], 'season': viewing['season'], 'rating': viewing['rating']}]
|
||||
viewing.pop('date_watched')
|
||||
viewing.pop('season')
|
||||
viewing.pop('rating')
|
||||
|
||||
watch_counts = Counter([x['imdb_id'] for x in viewings])
|
||||
repeat_watches = [k for k, v in watch_counts.items() if v > 1]
|
||||
|
||||
|
|
Loading…
Reference in New Issue