I have list of lists of sports matches:
table = [['Volleyball', ' Europe', 'European Championships'],
['Today 17:00', 'Moldova - Cyprus', '2.00', '1.72'],
['Handball', ' Slovenia', '1. NLB Liga'],
['Today 17:00', 'Krka - Slovenj Gradec', '2.05', '1.98'],
['American Football', ' USA', 'NCAA'],
['Today 17:00', 'Marshall - Eastern Kentucky', '1.90', '1.90'],
['Today 20:00', 'Army - Middle Tennessee St', '2.01', '1.99'],
['Tomorrow 20:00', 'West Virginia - Florida State', '2.50', '1.50'],
['Soccer', ' World', 'Club Friendly'],
['Today 17:00', 'UE Sants (Esp) - CE Europa (Esp)', '1.84', '1.88'],
['Today 17:00', 'Spain - France', '1.20', '2.80'],
['Tennis', ' USA', 'ATP US Open'],
['Today 17:30', 'Berrettini M. - Ruud C.', '1.81', '2.02']]
columns are:
sport country competition date match odd_1 odd_2
First 3 columns : [sport, country, competition] are always in one nested list, preceded by one or many list of columns [date, match, odd_1, odd_2]
I want to create the csv but I don't know how to associate each [date match odd_1 odd_2] data with it's specific [sport country competition]
I created this code:
with open(filename.csv, 'a', encoding='utf_8_sig') as csv_file:
w = csv.writer(csv_file, lineterminator='\n')
header =
w.writerow(header)
for row in table:
w.writerow(row)