-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.py
More file actions
39 lines (36 loc) · 2.49 KB
/
Test.py
File metadata and controls
39 lines (36 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
with open('Vaudeville_Tour_Listings.txt', 'r') as input_file:
data = input_file.read()
org_dict = json.loads(data)
x = org_dict.keys()
output_list = []
flat_dictionary_list = []
for date in x:
calendar_date = date
date_list =[date,[]]
cities = org_dict[date]
y = cities.keys()
for city in y:
city_name = city
venue_output_list = [city,[]]
#print("The City Is " + city)
venues = cities[city]
venue_list = venues.keys()
#print(venue_list)
for venue in venue_list:
venue_name = venue
#print("The Venue Is " + venue)
performers = venues[venue]
venue_and_performer_list = [venue, performers]
#print(venue_and_performer_list) venue_output_list[1].append(venue_and_performer_list)
for performer in performers:
performer = { "date" : date, "city_name" : city, "venue_name" : venue, "performer" : performer}
flat_dictionary_list.append(performer)
date_list[1].append(venue_output_list)
#print(venue_output_list[0]) #print(date_list)
output_list.append(date_list)
#print(date_list)
print(flat_dictionary_list)
with open ('Vaudeville_Flat_List.txt', 'w') as out_file:
for x in flat_dictionary_list:
out_file.write(json.dumps(x))