From the course: Python Code Challenges for Data Analysis
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Solution: Load JSONL data - Python Tutorial
From the course: Python Code Challenges for Data Analysis
Solution: Load JSONL data
- [Instructor] Let's just head over to the test section first, and I'm just going to select test my code. And you can see that the two tests we have here is the output. So I'm expecting the output from the get data to be a list, and there are going to be 234 entries in that list. So that's basically means there are going to be 234 films or movies that we have in this file. And also, I want to just confirm that the type that I'm returning is a list. Let's go ahead and work our way through reading the data from the JSON line file. So what I want to do is open my file. So with open, the file name is file name, and I want to read in the file and let's say as file. And now, I need to store all of the data in a list. So let me call my list, movies, and I want to work my way through the file. So for line in file and because it's a JSON object, I want to load it in. So let's me call that line, movie. So json dot and let me load my string and let me just test out the output. So I'm going to go…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.