-
-
Save benhosmer/3697171 to your computer and use it in GitHub Desktop.
f = open('user.yaml') | |
dataMap = yaml.load(f) | |
f.close() | |
print "" | |
print "=-----------=" | |
print "dataMap is a ", type(dataMap), dataMap | |
print "=-----------=" | |
print "main items are", type(dataMap['main']), dataMap['main'] | |
print "=-----------=" | |
print "main is a list, the first item is a dictionary", type(dataMap['main'][0]), dataMap['main'][0] | |
print "=-----------=" | |
print "main[0] is a dict, the first item is", dataMap['main'][0]['users'][0] | |
""" | |
Sample YAML File: | |
- users: | |
- joe | |
- mike | |
- sally | |
- path: | |
- /Users/me/files/ | |
- text.files | |
- search_phrases: | |
- Invalid users | |
- Failed password | |
""" |
sample files
--- meta: data_version: 0.6 created: 2011-05-06 revision: 1 info: city: Bangalore competition: IPL dates: - 2008-04-18 match_type: T20 outcome: by: runs: 140 winner: Kolkata Knight Riders overs: 20 player_of_match: - BB McCullum teams: - Royal Challengers Bangalore - Kolkata Knight Riders toss: decision: field winner: Royal Challengers Bangalore umpires: - Asad Rauf - RE Koertzen venue: M Chinnaswamy Stadium
File 2
--- meta: data_version: 0.6 created: 2011-05-06 revision: 1 info: city: Bangalore competition: IPL dates: - 2008-04-18 match_type: T20 outcome: by: runs: 140 winner: Kolkata Knight Riders overs: 20 player_of_match: - BB McCullum teams: - Royal Challengers Bangalore - Kolkata Knight Riders toss: decision: field winner: Royal Challengers Bangalore umpires: - Asad Rauf - RE Koertzen venue: M Chinnaswamy Stadium
@D-Pkya you have a break in the for loop causing the loop to end after the first iteration.
I am facing problem parsing multiple yaml files in directory. The for loop runs only for 1st file in directory.
Check my code
now the directory specified contains 3000 yaml files