Python Forum
Python Script for parsing dictionary values from yaml file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Script for parsing dictionary values from yaml file
#4
Tried the following with no luck


import os
import yaml

def yaml_loader(filepath):
    """Loads a yaml file """
    with open(filepath, "r") as file_descriptor:
        data = yaml.load(file_descriptor)
    return data


if __name__ == "__main__":
    filepath = "latest123.yaml"
    data = yaml_loader(filepath)
    print (data)

    items = data.get('releases')
    for item,name, item_value in items.iteritems():
        print (item_name, item_value)
Reply


Messages In This Thread
RE: Python Script for parsing dictionary values from yaml file - by pawan6782 - Sep-04-2019, 07:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Using Lists as Dictionary Values bfallert 8 386 Apr-21-2024, 06:55 AM
Last Post: Pedroski55
  need to compare 2 values in a nested dictionary jss 2 893 Nov-30-2023, 03:17 PM
Last Post: Pedroski55
  save values permanently in python (perhaps not in a text file)? flash77 8 1,267 Jul-07-2023, 05:44 PM
Last Post: flash77
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,352 Jun-29-2023, 11:57 AM
Last Post: gologica
  Python Script to convert Json to CSV file chvsnarayana 8 2,580 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
Video doing data treatment on a file import-parsing a variable EmBeck87 15 2,968 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
  Printing specific values out from a dictionary mcoliver88 6 1,463 Apr-12-2023, 08:10 PM
Last Post: deanhystad
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,236 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  Trying to use 2 values from excel in my script but getting error.. cubangt 3 1,700 May-11-2022, 07:12 AM
Last Post: normanwolf
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,726 Apr-13-2022, 06:02 AM
Last Post: Paqqno

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020