Parse yaml into a list in python -
i required use yaml project. have yaml file using populate list in python program interacts data.
my data looks this:
employees: custid: 200 user: ash - smith - cox
i need python code iterate on yaml file , populate list this:
list_of_employees = ['ash', 'smith' 'cox']
i know must open file , store data in variable, cannot figure out how enter each element separately in list. ideally use append function don't have determine 'user' size every time.
with open("employees.yaml", 'r') stream: out = yaml.load(stream) print out['employees']['user']
should give list of users.also note yaml missing 1 dash after user node
Comments
Post a Comment