Skip to content

chauhan081/Python-Project-7-Read-Write-JSON-Files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Python Project 7: Read & Write JSON Files πŸ”„πŸ“„

πŸ“Œ Problem Statement:

Create a Python script that reads data from a JSON file, manipulates it, and writes the updated data back to a new JSON file.

🧠 What You'll Learn:

  • Working with JSON using Python's json module
  • Parsing nested structures
  • Reading & writing files

βœ… Python Code:

import json

Read JSON file
with open("data.json", "r") as f:
    data = json.load(f)
    print("Original Data:")
    print(data)

Modify data (example: add a new key)
data["status"] = "processed"

Write to a new JSON file
with open("updated_data.json", "w") as f:
    json.dump(data, f, indent=4)

print("\nUpdated JSON saved!")

πŸ“₯ How It Works:

  • Loads data.json
  • Adds or updates values in the dictionary
  • Writes the updated data to updated_data.json

πŸ”§ Try modifying:

– Loop through a list of items
– Extract nested values
– Merge multiple JSON files

πŸ’‘ Use Cases:

– Handling API responses
– Config file updates
– User data storage

About

Create a Python script that reads data from a JSON file, manipulates it, and writes the updated data back to a new JSON file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors