help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
healthcare-patients
RSK World
healthcare-patients
Healthcare Patients Dataset - Medical Analytics + Healthcare Data Science + Patient Data Analysis
healthcare-patients
  • visualizations
  • .gitignore785 B
  • ADVANCED_FEATURES.md5.8 KB
  • FILES_SUMMARY.md2.8 KB
  • GITHUB_PUSH_SUMMARY.md3.4 KB
  • IMAGE_DESCRIPTION.md1.6 KB
  • LICENSE1.2 KB
  • PROJECT_INFO.md2.2 KB
  • PROJECT_SUMMARY.md5.7 KB
  • QUICKSTART.md1.7 KB
  • README.md5.4 KB
  • RELEASE_NOTES.md7.4 KB
  • advanced_analysis.py13.7 KB
  • advanced_analysis_report.txt2.3 KB
  • analyze_patients.py13.8 KB
  • export_to_excel.py6 KB
  • export_to_json.py3.5 KB
  • healthcare_patients.csv6.5 KB
  • healthcare_patients.json27.2 KB
  • healthcare_patients.xlsx14.6 KB
  • index.html26 KB
  • requirements.txt578 B
  • validate_data.py6 KB
export_to_json.py
export_to_json.py
Raw Download
Find: Go to:
"""
Export Healthcare Patient Dataset to JSON
==========================================
This script exports the healthcare patient dataset to JSON format
with nested structure and metadata.

Author: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
"""

import pandas as pd
import json
from datetime import datetime

def export_to_json(csv_file='healthcare_patients.csv', json_file='healthcare_patients.json'):
    """
    Export CSV dataset to JSON format.
    
    Parameters:
    csv_file (str): Path to input CSV file
    json_file (str): Path to output JSON file
    """
    try:
        print(f"Reading CSV file: {csv_file}")
        df = pd.read_csv(csv_file)
        
        # Convert dates to strings
        df['admission_date'] = pd.to_datetime(df['admission_date']).dt.strftime('%Y-%m-%d')
        df['discharge_date'] = pd.to_datetime(df['discharge_date']).dt.strftime('%Y-%m-%d')
        
        # Create structured JSON with metadata
        json_data = {
            'metadata': {
                'dataset_name': 'Healthcare Patient Dataset',
                'description': 'Medical patient dataset with health records, diagnostic information, and treatment outcomes',
                'total_patients': len(df),
                'total_features': len(df.columns),
                'export_date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                'author': {
                    'name': 'RSK World',
                    'website': 'https://rskworld.in',
                    'email': 'help@rskworld.in',
                    'phone': '+91 93305 39277'
                }
            },
            'statistics': {
                'mean_age': float(df['age'].mean()),
                'mean_length_of_stay': float(df['length_of_stay'].mean()),
                'total_charges': float(df['charges'].sum()),
                'mean_charges': float(df['charges'].mean()),
                'readmission_rate': float((df['readmission_30_days'] == 'Yes').sum() / len(df) * 100)
            },
            'patients': df.to_dict('records')
        }
        
        # Export to JSON
        print(f"Creating JSON file: {json_file}")
        with open(json_file, 'w', encoding='utf-8') as f:
            json.dump(json_data, f, indent=2, ensure_ascii=False)
        
        print(f"[OK] JSON file created successfully: {json_file}")
        print(f"  - Total patients: {len(df)}")
        print(f"  - File size: {len(json.dumps(json_data)) / 1024:.2f} KB")
        return True
        
    except FileNotFoundError:
        print(f"[ERROR] File '{csv_file}' not found")
        return False
    except Exception as e:
        print(f"[ERROR] Error creating JSON file: {str(e)}")
        return False

def main():
    """
    Main function to export dataset to JSON.
    """
    print("\n" + "="*60)
    print("HEALTHCARE PATIENT DATASET - JSON EXPORT")
    print("="*60)
    print("Author: RSK World")
    print("Website: https://rskworld.in")
    print("Email: help@rskworld.in")
    print("Phone: +91 93305 39277")
    print("="*60 + "\n")
    
    success = export_to_json()
    
    if success:
        print("\n" + "="*60)
        print("EXPORT COMPLETE!")
        print("="*60)
        print("\nThe JSON file contains:")
        print("  - Metadata (dataset information)")
        print("  - Statistics (key metrics)")
        print("  - Patients (complete patient records)")
        print("\n")

if __name__ == "__main__":
    main()

103 lines•3.5 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer