I have a large dictionary with time format values. the example of the dictionary is "mydict". each list([[]]) shows times of a week. Each times of a day divided with ','. For example saturday times are 06:00 - 09:30 AM - 10:30 AM - 14:00 - 17:00 - 21:00. and Sunday times are 07:00 - 09:30 AM - 11:30 AM - 14:00 - 16:00 - 21:00 in the dictionary. The dictionary involves times of 7 days and thousands key/values.
I also have a string with a specific format for 7 days. I simplified the string to 2 days. I want to replace "dayname", "endTime" and "startTime" values of the string with the nested list of the dictionary then write it in dictionary format. My ideal result is shown below.
How can i solve the issues?
mydict= {'x': [['06:00 - 09:30 AM - 10:30 AM - 14:00 - 17:00 - 21:00, 07:00 - 09:30 AM - 11:30 AM - 14:00 - 16:00 - 21:00']]}
Expected Output:
{'x': [{
"DayName": "saturday",
"timeList": [
{
"endTime": "06:00",
"startTime": "09:30"
},
{
"endTime": "10:30",
"startTime": "14:00"
},
{
"endTime": "17:00",
"startTime": "21:00"
}
]
},
{
"DayName": "sunday",
"timeList": [
{
"endTime": "07:00",
"startTime": "09:30"
},
{
"endTime": "11:30",
"startTime": "14:00"
},
{
"endTime": "16:00",
"startTime": "21:00"
}
]
}]}
mydictis not a valid python dictionary did you posted the correct dictionarymydict= {'x': [['06:00 - 09:30 AM - 10:30 AM - 14:00 - 17:00 - 21:00', '07:00 - 09:30 AM - 11:30 AM - 14:00 - 16:00 - 21:00']]}is this correct? comma inside the quotes?