Linked Questions
12 questions linked to/from Parsing a YAML file in Python, and accessing the data?
690
votes
46
answers
514k
views
How to convert a nested Python dict to object?
I'm searching for an elegant way to get data using attribute access on a dict with some nested dicts and lists (i.e. javascript-style object syntax).
For example:
>>> d = {'a': 1, 'b': {'c':...
1155
votes
10
answers
1.6m
views
How can I parse a YAML file in Python
How can I parse a YAML file in Python?
132
votes
4
answers
244k
views
How to parse/read a YAML file into a Python object?
How to parse/read a YAML file into a Python object?
For example, this YAML:
Person:
name: XYZ
To this Python class:
class Person(yaml.YAMLObject):
yaml_tag = 'Person'
def __init__(self, name)...
23
votes
2
answers
65k
views
Parse yaml into a list in python
I am required to use YAML for a project. I have a YAML file which I am using to populate a list in a Python program which interacts with the data.
My data looks like this:
Employees:
custid: 200
...
0
votes
2
answers
7k
views
Need a script that extracts from a yaml file content and output as a csv file
I'm very new to python but I would appreciate your help in guiding me in creating a simple script that reads through a bunch of .yaml files (about 300 files in the same directory) and extracts a ...
-1
votes
2
answers
6k
views
Import from YAML file
I have a config.yaml file that I want to import in my app.py.
This is my folder structure:
/root
__init__.py
app.py
config.yaml
App.py:
import logging
import config
from ...
1
vote
3
answers
2k
views
How to read a file which contains the questions and answers for a quiz saved as the string representation of a list?
I'm creating a quiz in Python that you can edit, but one of the sections needs the questions to be saved in a file. In this section of code, I'm trying to read the file and then put what it has read ...
1
vote
1
answer
4k
views
Import YAML variables automatically?
I've provided the code below. I'm just wondering if there's a better, more concise, way to load the entire index into variables, instead of manually specifying each one...
Python code
script_dir = ...
1
vote
1
answer
3k
views
YAML with Python using PyYAML
I am trying to follow these two examples:
Parsing a YAML file in Python, and accessing the data?
YAML parsing and Python?
but for some reason I keep getting the following error message:
Traceback (...
2
votes
2
answers
907
views
Extending pyyaml to find and replace like xml ElementTree
I'd like to extend this SO question to treat a non-trivial use-case.
Background: pyyaml is pretty sweet insofar as it eats YAML and poops Python-native data structures. But what if you want to find a ...
0
votes
2
answers
1k
views
Edit yaml file with Python
In this answer it was described how to edit specific entries of yaml files with python. I tried to use the code for the following yaml file
- fields: {domain: "www.mydomain.com", name: "www.mydomain....
-6
votes
2
answers
3k
views
tokenizing and parsing with python
I don't have a code to show to you because I have no idea on how to start.
The current target is to at least be able to create tokens from a file that contains some data
eg:
file.txt
Name : Sid
data : ...