From the course: Practical GitHub Copilot

Output to YAML - Github Copilot Tutorial

From the course: Practical GitHub Copilot

Output to YAML

- [Instructor] Right now, it's a little bit difficult to read the data in the format that it's being output in, so I'm going to ask it to print the result in YAML format, and I'll get some code for that. So I'll say, "can you get this code to print the results in a YAML format so it's easier to read?" Just check this out. All right, so you can use the PyYAML library to convert the results. That's great. It's given me some good code. Let's go ahead and select all this and just replace this with the new code. I think that if I try to run this, I'm going to get the same problem, which means that I need to install this YAML file. You can see by this yellow squiggles. Now I know that I need to install a library called PyYAML, but you may just forget and try just running pip3 install yaml, and you'll get an error like this, says, "Could not find a version that satisfies the requirement." So let's just see what ChatGPT says about this error. See if it notices errors from the terminal and tells me what I need to do. "I'm getting an error in the terminal like this," and then I'll paste the error. Let's see what it says. "The error message suggests that the PyYAML library is not installed in your Python environment," and it accurately tells me that I need to install YAML with pip install pyyaml. Now, I'm on a Mac, so I know that I need to say pip3 install pyyaml, and it's going to do that correctly. I'm going to clear this out. Let's go ahead and try to run this and see what happens. Looking at the output, looks like I'm getting some of the text here, but whenever it gets to the comments, it looks like it's outputting a bunch of sort of additional things. So I think the comments are in a sequence of objects that it's having a problem parsing. So what I want to do is see if I can just convert the comments to a simple string. So let's go ahead and see if ChatGPT can help me with that. Say, "can you convert the comments from the ID3 tags to a string for cleaner output?" Let's try that. All right, so it says that you can... Let's see if we can make this bigger. Yeah, convert this into a string like this. So this'll work pretty well. Let's select all this and just replace this, and we'll try running this again. And it looks like that's fixing it, mostly. It's probably not the best way to look at YAML. There you go. That made the window a little bit bigger and it ended up looking a little bit better. So now it looks like if it's got comments and then the title, so that at least doesn't have all of the other information that was making it look really weird, and so that's definitely an improvement. I really like that it's able to take a look at errors and give me some information, like when I have to import additional items and I can copy and paste things from the terminal and other parts of the environment. So it's really a pretty useful tool, when you think about it.

Contents