How can we parse a file which contains multiple configs and which are separated by --- in python.
I've config file which looks like
File name temp.yaml
%YAML 1.2
---
name: first
cmp:
- Some: first
top:
top_rate: 16000
audio_device: "pulse"
---
name: second
components:
- name: second
parameters:
always_on: true
timeout: 200000
When I read it with
import yaml
with open('./temp.yaml', 'r') as f:
temp = yaml.load(f)
I am getting following error
temp = yaml.load(f)
Traceback (most recent call last):
File "temp.py", line 4, in <module>
temp = yaml.load(f)
File "/home/pranjald/.local/lib/python3.6/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/home/pranjald/.local/lib/python3.6/site-packages/yaml/constructor.py", line 41, in get_single_data
node = self.get_single_node()
File "/home/pranjald/.local/lib/python3.6/site-packages/yaml/composer.py", line 43, in get_single_node
event.start_mark)
yaml.composer.ComposerError: expected a single document in the stream
in "./temp.yaml", line 3, column 1
but found another document
in "./temp.yaml", line 10, column 1