Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: create_example_json.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- # For use with 'parity_number_counter.py': https://pastebin.com/KcCdq19X
- """
- Description:
- This script creates an example JSON file ('example.json') with sample data.
- Requirements:
- - Python 3.x
- Usage:
- 1. Save this script as 'create_example_json.py'.
- 2. Run the script.
- Note: Adjust the 'json_filename' variable in the script as needed.
- """
- import json
- def create_example_json(json_filename):
- people_data = [
- {
- "name": "John Doe",
- "age": 30,
- "city": "New York",
- "interests": ["reading", "traveling", "coding"],
- "salary": 75000.50,
- "experience_years": 5,
- "height_cm": 180,
- "weight_kg": 75.5,
- "savings": 120000.75,
- "days_of_vacation": 20,
- "average_speed_kmph": 45.5
- },
- {
- "name": "Jane Smith",
- "age": 25,
- "city": "Los Angeles",
- "interests": ["hiking", "photography", "music"],
- "salary": 65000.75,
- "experience_years": 3,
- "height_cm": 165,
- "weight_kg": 60.2,
- "savings": 95000.20,
- "days_of_vacation": 15,
- "average_speed_kmph": 40.0
- },
- # Add more people as needed
- ]
- with open(json_filename, 'w') as jsonfile:
- json.dump(people_data, jsonfile, indent=2)
- if __name__ == "__main__":
- # Set the filename for the example JSON file
- json_filename = 'example.json'
- # Create the example JSON file in the current working directory
- create_example_json(json_filename)
- print(f"Example JSON file '{json_filename}' created in the current working directory.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement