I have the following kind of dictionary:
my_dict
my_dict = {
'table':
{
'description': 'Table 1',
'columns': [
{'name': 'Column1',
'description': 'first column'
},
{'name': 'Column2',
'description': 'second column'
},
{'name': 'Column3',
'description': 'third column'
}
]
}
}
I want to write this dictionary and get the YAML file using the following script.
with open('Table1.yaml', 'w') as f:
yaml.dump(my_dict, f)
The result that I got on the YAML file looks like the following:
table:
description: Table 1
columns:
- name: Column1
description: first column
- name: Column2
description: second column
- name: Column3
description: third column
But I would like to get the description value in the quote below:
table:
description: 'Table 1'
columns:
- name: Column1
description: 'first column'
- name: Column2
description: 'second column'
- name: Column3
description: 'third column'
Can anyone help on how to add the quotes for every description key value?