markup: spreadsheet handle multiple materials in a match
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user