Basic Python Tutorial Series: 23 – YAML files

///Basic Python Tutorial Series: 23 – YAML files

Basic Python Tutorial Series: 23 – YAML files

FavoriteLoadingAdd to favorites

Learn how to read and write to YAML files inside of python. Learn how to use the YAML data inside python. #learnpython #gamedev #roguelike #yaml

source

By |2020-04-12T02:59:52+00:00April 12th, 2020|Python Video Tutorials|11 Comments

11 Comments

  1. Rama Rama April 12, 2020 at 2:59 am - Reply

    To give feedback the video should be visible and audio should be audible. Both r not there…

  2. Sven April 12, 2020 at 2:59 am - Reply

    #########
    # Read and write txt file with YAML
    # code from ' Basic Python Tutorial Series: 23 – YAML files '
    #########

    import yaml # pip install PyYAML

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

    def yaml_dump(filepath, data): # Dumps data to a yaml file
    with open(filepath, 'w') as file_descriptor:
    yaml.dump(data, file_descriptor)

    if _name_ == '__main__':
    pass

  3. A Xin Trương April 12, 2020 at 2:59 am - Reply

    nice men

  4. lavitha Pereira April 12, 2020 at 2:59 am - Reply

    import yaml

    file_path= "/data/ipl_match.yaml"
    def read_data(file_path):
    with open(file_path, "r") as f:
    data = yaml.load(f)
    return data

    yaml.dump(data)

    I am getting error as below:
    <ipython-input-13-766479eabfef> in <module>()
    7 return data
    8
    —-> 9 yaml.dump(data)

    NameError: name 'data' is not defined

  5. Signals Daily April 12, 2020 at 2:59 am - Reply

    << Like #100

  6. Anji Anand April 12, 2020 at 2:59 am - Reply

    Thanks for Ur Video on yaml file reader and writing , Could you please provide me Unit test case for writing yaml file and reading yaml file ?

  7. beingme2345 April 12, 2020 at 2:59 am - Reply

    I'm not 100% sure but I think that the on line 19 where you user itemitems(), items() should be used instead. When I used iteritems() I got the wrong output but items() gave the desired output. It might have something to do with the fact that the functions have changed with python 3 and you are using python 2.

    Here is the documentation I used for reference if anyone is interested.

    https://docs.python.org/3.5/library/mailbox.html#mailbox.Mailbox.iteritems

  8. Buğra Coşkun April 12, 2020 at 2:59 am - Reply

    I feel like you always smash the return button which makes me worried for your macbook keyboard !

  9. Alexander Wortham April 12, 2020 at 2:59 am - Reply

    Thanks for the video but if I may make a suggestion, turn your mic up a little!

  10. Pawankumar Dubey April 12, 2020 at 2:59 am - Reply

    I have raised an query on stack. Can you help me out with that ? http://stackoverflow.com/questions/37487250/how-to-update-yaml-file-using-python

  11. Donner April 12, 2020 at 2:59 am - Reply

    What is "iteritems" in line 19?

Leave A Comment

*