 and welcome. Today, we're going to continue working with different file formats. We've looked at converting different types of spreadsheets to CSV files, and we've looked at converting CSV files into JSON files. Now, we're going to be looking at parsing through. That means going through and pulling stuff out of the JSON file. So, if I list out here, we've got a couple of spreadsheet files. We've got a CSV file and a JSON file. And again, CSV files and JSON files are both plain text, plain ASCII characters. That means you can just, you can read them. As a person, I can say, cat, people, yes, well, people write people.csv. And I can see, I can read those names, I can read those address, and there'll be a link to this file in the description of the video, by the way, the CSV file anyway. All right, I guess I'll put the JSON file since that's what we're working with. Anyway, and the JSON file is similar. You can read it. It's formatted a little bit different. It actually makes it a larger file because you have more text, but it makes it easier to pull out the information you want. And right here, it's an array of people. There's about almost 900, 800 some people in here. We got birth dates, addresses. This is a file I've created, a list of people I created based on real people from voter registration, but I shuffled up all the names, addresses, and changed the numbers. So, basically, it's similar to real information, but it's not real people information. So, you can use it for your projects for testing. Anyway, again, I can go through here and find what I'm looking for. You know, you could go old school route like if I want to, I could say grep jones, and we'll make that a capital J from our people.json file, you know, and I found jones and I can say, okay, dash, let's see, jones last name is there. So, I can say dash A3 dash B, I'll say five, I'm just eyeballing this. So, I'm saying fine, everyone, any line says jones, show me the three lines before and the three lines after. And so, there we go. We can kind of see these people. So, now I'm just looking at everyone named jones. So, you know, you could do something like that, but that's not what we're looking to do. We want to be a little more specific. So, what we're going to do here is we're going to use the jq command. And if I use my package manager, I say aptitude search jq, and I'll say less on that so I can see the list. It's going to bring up every file that has word jq in it, but you'll see there is a program called jq. You see this, I have it installed and it is a lightweight and flexible command line JSON processor. So, now what I can do is I can just cat out JSON, my people.json, and I can put that, pipe that into jq and it's going to be just like catting it out, only it colorizes for me. And if my file wasn't formatted so nicely, I'm pretty sure jq would have formatted like if everything was on one line and there wasn't indentation, jq I think would have done that. But right here all it's done for us since my file is already formatted properly. It's giving us basically our fields, our field names highlighted in blue in this case. But let's say I wanted to grab just the first entry in here. What I can do is I can say since this is an array, as you can see I have, is the brackets here. So everything, every entry in here is an array. I can say I want zero would be the first array. No, that's not, that's not right. Oh, sorry. Dot bracket zero. There we go. That's the first entry. I can go to the third entry by doing two, five all the way through. But what I can also do is if I leave it like that, it's going to show all the entries. But then I can say dot, I want just the last name of everybody, L name. So now it's listing all the last names. Or I can do the F name for the first names or zip for zip code. But if I wanted the fifth entry, actually that would be the sixth entry since we start with zero. I want the fifth entry's zip. I can do that and it just gives me the fifth entry zip. Or I can say the 333rd, which is really the 334th entry, I can get their zip code, which is the same as theirs. Let's do something other than zip. Let's do L name. So there, there's their L name. And I'll change that to two. And that's their last name. Now we're piping this in directly from a final directory, but we can also use W get or curl to pull something from the Internet. So I'm just going to real quick do go up through here because I already have this in here. Here we go. So here's a link to just an example from some web page, an example JSON file. So I'm using W get, I'm using dash Q for quiet so it doesn't give me a percentage bar of what's downloading and doing. Capital O is output and the dash just means standard output. I'll go ahead and hit enter. And there's that file. And again, I can pipe that into JQ. And it's just going to format if it's not format and colorize things for me. Let's go ahead and do less so I can look at this file. And maybe less was not a good option. I'll just JQ and then I'll scroll up. So here you can see the main entry here is called quiz. And that we have maths. So if I want to go and I want to look at the sports, I can tell sports or I can say maths. Let's just go here and I'll pipe and then JQ and send the quotation here. I'm going to say quiz. So now it's going to show me just the quiz and I can say dot maths. There's no brackets here because so far we haven't hit an array. So there's the math. So there's two questions in the math quiz. So now I can say, I want to look at question one so dot question one. And it's going to show us just question one. And here I can get the question by saying question question. And if I wanted to see the options, I can say options. And it's going to show me the options which is an array as you can see the brackets there. So what I can do here is I can say options and I can say two, which should give us 12. Yep. And if I said zero, that would give us the 10. So I'm going through that. But if I didn't want options, let's say I just want the answer. I can get the answer. Is it answer? Yeah, answer. And the answer is 12. So that is just a quick look at using JQ. And here I'm piping directly from a JSON from a website into JQ. And this is a lot of times you'll use JSON, you know, on websites. So if a website has an API where you have a URL where you can grab information, you can directly use curl or W get to pipe directly into JQ and pull the information out. And you don't have to use Oc and set and grab and all these different tools to try to try to grab what you need. You could do it that way. If you don't have JQ on a very lightweight system, you could definitely do that. It's one of the benefits of having plain text files. But JQ is designed for parsing. You don't have to worry about, you know, some formatting that's might throw you off. And it's very easy, especially when you get into things with arrays, we're looking at very small files here. But if you had a large file, then it was definitely be a way to quickly do it. So go ahead, check out your repositories. If not, search GitHub. JQ is on GitHub. And I do thank you for watching. Please visit filmsbychrist.com. That's Chris of the K. There's a link in the description of the video to my website, so as my Patreon page. And also you can support me in the support section. There's a link on my website to my Patreon and to PayPal. I thank you for watching. And as always, I hope that you have a great day.