From ed5236c618554a853b0cb4bf304c7cec9423f01f Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Sat, 19 Oct 2019 17:02:28 -0700 Subject: [PATCH] markup: spreadsheet handle multiple materials in a match --- markup/spreadsheet.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/markup/spreadsheet.py b/markup/spreadsheet.py index e393f87..b24f66f 100644 --- a/markup/spreadsheet.py +++ b/markup/spreadsheet.py @@ -1,4 +1,5 @@ import os +from itertools import zip_longest from openpyxl import Workbook from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font @@ -10,7 +11,7 @@ def format_season(s): if not s or len(s) < 4: return s - # 'SS20' -> 'S20' + # 'FW20' -> 'F20' return s[:1] + s[2:] @@ -25,7 +26,16 @@ def write_spreadsheet(matches, subdir, catname, filename): ws.append(['Season', 'Gender', 'Name', 'Style Number', 'Color']) for m in matches: - ws.append([format_season(m['season']), m['gender'], m['name'], m['material'], m['color']]) + # in the case of kids, + # we might have multiple products in a match + seasons = m['season'].split('\n') + genders = m['gender'].split('\n') + names = m['name'].split('\n') + materials = m['material'].split('\n') + colors = m['color'].split('\n') + + for s, g, n, m, c in zip_longest(seasons, genders, names, materials, colors, fillvalue=''): + ws.append([format_season(s), g, n, m, c]) # # Python types will automatically be converted # import datetime