Jun-23-2021, 11:53 AM
I have four lists named designName,creatorName,fabric_names and data the data list consist of multiple duplicate values which I want to map it to it's asscociated design name and creator name like:
Output:Catching Fireflies thestorysmith FABRIC_PETAL_SIGNATURE_COTTON 1.75 10.58 18.22
Catching Fireflies thestorysmith FABRIC_SATIN 1.75 11.85 19.71
Catching Fireflies thestorysmith FABRIC_COTTON_POPLIN_BRAVA 1.75 11.85 19.71....
Spoonflower Color Map spoonflower_help FABRIC_PETAL_SIGNATURE_COTTON N/A N/A 16.4
Spoonflower Color Map spoonflower_help FABRIC_SATIN N/A N/A 17.74
Spoonflower Color Map spoonflower_help FABRIC_COTTON_POPLIN_BRAVA N/A N/A 17.74...
Night Sky Stars Midnight Blue at_the_cottage FABRIC_PETAL_SIGNATURE_COTTON 1.75 10.58 18.22
Night Sky Stars Midnight Blue at_the_cottage FABRIC_SATIN 1.75 11.85 19.71
Night Sky Stars Midnight Blue at_the_cottage FABRIC_COTTON_POPLIN_BRAVA 1.75 11.85 19.71
Data:desigName = ['Catching Fireflies', 'Spoonflower Color Map', 'Night Sky Stars Midnight Blue'] creatorName = ['thestorysmith', 'spoonflower_help', 'at_the_cottage'] fabric_names = ['FABRIC_PETAL_SIGNATURE_COTTON', 'FABRIC_SATIN', 'FABRIC_COTTON_POPLIN_BRAVA'] data = [('FABRIC_PETAL_SIGNATURE_COTTON', 1.75, 10.58, 18.22),('FABRIC_PETAL_SIGNATURE_COTTON', 1.75, 10.58, 18.22),('FABRIC_PETAL_SIGNATURE_COTTON', 1.75, 10.58, 18.22),... ('FABRIC_SATIN', 1.75, 11.85, 19.71),('FABRIC_SATIN', 1.75, 11.85, 19.71),('FABRIC_SATIN', 1.75, 11.85, 19.71),... ('FABRIC_COTTON_POPLIN_BRAVA', 1.75, 11.85, 19.71),('FABRIC_COTTON_POPLIN_BRAVA', 1.75, 11.85, 19.71),('FABRIC_COTTON_POPLIN_BRAVA', 1.75, 11.85, 19.71),...]I am trying to figure out the best way to turn this data into one ordered dict like the following.
Output:{('Catching Fireflies', 'thestorysmith'): {'fabric_name_00': 'FABRIC_PETAL_SIGNATURE_COTTON', 'test_swatch_meter_00': 1.75, 'fat_quarter_meter_00': 10.58, 'meter_00': 18.22, 'fabric_name_01': 'FABRIC_SATIN', 'test_swatch_meter_01': 1.75, 'fat_quarter_meter_01': 11.85, 'meter_01': 19.71, 'fabric_name_02': 'FABRIC_COTTON_POPLIN_BRAVA', 'test_swatch_meter_02': 1.75, 'fat_quarter_meter_02': 11.85, 'meter_02': 19.71}}
I've tried so far:for fab in fabric_names: print(fab) for name, creator in zip(designName, creatorName): for fab_type in fabric_names: Design_Name = name Creator_Name = creator test_swatch_meter = data[1] fat_quarter_meter = data[2] meter = data[3] if (name, creator) not in items_dict.keys(): items_dict[(name, creator)] = {} itemCount = len(items_dict[(name, creator)].values()) / 4 items_dict[(name, creator)].update({'fabric_name_%02d' %itemCount: fab_type, 'test_swatch_meter_%02d' %itemCount: test_swatch_meter, 'fat_quarter_meter_%02d' %itemCount: fat_quarter_meter, 'meter_%02d' %itemCount: meter})but cannot get it to format like above.