Extracting data from a JSON file in Python

0 votes
How do I parse a JSON file in python to read data from it?
Apr 19, 2018 in Python by noidea
5,696 views

2 answers to this question.

0 votes
import json
from pprint import pprint

data = json.load(open('data.json'))

pprint(data)

This will store the JSON data in the dictionary named data. 

pprint() simply prints your data in a neat manner, preserving the indentation

answered Apr 19, 2018 by Nietzsche's daemon
• 4,260 points
0 votes
Here is what i found and was pretty useful too.

In this documentation you can find how to play with your json file.

https://stackabuse.com/reading-and-writing-json-to-a-file-in-python/
answered Nov 27, 2018 by Rupali

Related Questions In Python

0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
547 views
0 votes
1 answer

Need help extracting a schema to make use for an avro file in Python

Hi, nice question. So what I daily use ...READ MORE

answered Jan 10 in Python by Nymeria
• 3,500 points
343 views
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29 in Python by Nymeria
• 3,500 points
37 views
0 votes
1 answer

How can I read numbers in Python from a custom file?

Hi, good question. Let us first assume that ...READ MORE

answered Feb 6 in Python by Nymeria
• 3,500 points
56 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 128 views
+4 votes
6 answers
0 votes
1 answer

Create and open a file in Python

file = open('text.txt', 'w+) READ MORE

answered May 24, 2018 in Python by Nietzsche's daemon
• 4,260 points
42 views
+4 votes
7 answers

Splitting a List into chunks in Python

Here's a generator that yields the chunks ...READ MORE

answered Apr 13, 2018 in Python by Nietzsche's daemon
• 4,260 points
3,023 views