Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

41 Commits

Folders and files

Repository files navigation

πŸ₯ AMR Data Harmonizer

Advanced Data Processing & Standardization Platform for AMR Surveillance

Python Streamlit CI/CD Pipeline License

A comprehensive platform designed to address critical data cleaning challenges in Antimicrobial Resistance (AMR) surveillance across African laboratories. This tool helps laboratories prepare their data for submission to global surveillance systems like GLASS and WHONET.

Application Overview

App β€” Workflow Selection

App Workflow Selection

Main interface with sidebar navigation and workflow selection.

App β€” Workflow Cards

App Workflow Cards

Choose Your Workflow: Standardize Single File, Merge Multiple Files (Recommended), and AMR Analytics.

About Page

About Page

Platform overview, challenges, solutions, and features with quick navigation.

πŸš€ Quick Start

Option 1: Streamlit Cloud Deployment (Recommended for Sharing)

Deploy to Streamlit Cloud

  1. Push your code to GitHub (this repository)
  2. Go to share.streamlit.io
  3. Connect your repository: drmichaeladu/data-standardizer
  4. Set main file path: app.py
  5. Click "Deploy" and wait for deployment to complete
  6. Your app will be live at https://your-app-name.streamlit.app

Note: For Streamlit Cloud, ensure your requirements.txt includes all dependencies.

Option 2: Local Development Setup

Windows (Easy Launch)

# Double-click or run (starts in detached mode - works in all terminals):
launch.bat

# For interactive logs in CMD, use:
launch.bat -f

Linux/macOS

# Make scripts executable
chmod +x deploy_production.sh scripts/deploy.sh

# Run deployment script
./deploy_production.sh

Option 3: Manual Setup (Local)

# 1. Create virtual environment
python -m venv .venv

# 2. Activate virtual environment
# Windows:
.venv\Scripts\activate
# Linux/macOS:
source .venv/bin/activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Run application
python run.py
# OR for production mode:
python run_production.py

Option 4: Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

# Access at http://localhost:8501

πŸ“‹ System Requirements

  • Python: 3.8 or higher (3.10+ recommended)
  • Memory: 4GB RAM minimum, 8GB recommended
  • Storage: 1GB free space
  • OS: Windows 10+, macOS 10.14+, Linux (Ubuntu 18.04+)

✨ Features

Core Functionality

  • πŸ“ Single File Processing: Upload, analyze, transform, and export individual files

    • Column mapping & renaming
    • Data transformation and cleaning
    • Quality validation
    • Multi-format export (CSV, Excel, JSON, XML)
  • πŸ“Š Multiple File Merging: Intelligent merging of multiple Excel/CSV files

    • πŸ†• Excel Sheet Selection: Choose specific sheets from Excel files before merging
    • Smart column matching with fuzzy logic
    • Automatic data harmonization
    • Duplicate detection and audit
    • Shared column mapping across files
    • One-file-at-a-time processing workflow
  • 🧬 AMR Analytics: Professional antimicrobial resistance analysis with CLSI compliance

    • CLSI-compliant analysis (M100-S33, M02-A13)
    • Resistance rate calculations with confidence intervals
    • MDR/XDR/PDR classification
    • Professional visualizations and heatmaps
    • Statistical validation
  • 🎯 Data Preparation Wizards:

    • GLASS Preparation Wizard: Step-by-step guided process for GLASS submission
    • WHONET Preparation Wizard: Step-by-step guided process for WHONET import
    • Automatic data cleaning and standardization
    • Built-in format validation
    • Comprehensive quality reports

Advanced Features

  • πŸ”— Smart Column Mapping: AI-powered column matching with fuzzy matching and AST-specific patterns
  • πŸ”„ Data Transformation: Comprehensive data cleaning and standardization
  • πŸ“ˆ Quality Assessment: Advanced data quality metrics and validation
  • πŸ“€ Multi-format Export: Export to CSV, Excel, JSON, XML formats
  • πŸ›‘οΈ Production Ready: Error handling, logging, monitoring, and security

Production Features

  • πŸ›‘οΈ Error Handling: Comprehensive error logging and recovery
  • πŸ“Š Performance Monitoring: Real-time performance metrics and optimization
  • βœ… Data Validation: Multi-level data validation and quality checks
  • πŸ’Ύ Memory Optimization: Automatic DataFrame optimization
  • βš™οΈ Configuration Management: Centralized settings and customization
  • πŸ”’ Security: File upload validation, rate limiting, input sanitization

πŸ—οΈ Architecture

data-standardizer/
β”œβ”€β”€ app.py                      # Main Streamlit application
β”œβ”€β”€ run.py                      # Development launcher
β”œβ”€β”€ run_production.py           # Production launcher
β”œβ”€β”€ launch.bat                  # Windows quick launcher
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ .gitignore                  # Git ignore rules
β”œβ”€β”€ docker-compose.yml          # Docker deployment config
β”œβ”€β”€ deploy_production.sh        # Production deployment script
β”‚
β”œβ”€β”€ config/                     # Configuration modules
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── production.py          # Production configuration
β”‚
β”œβ”€β”€ utils/                      # Core utility modules
β”‚   β”œβ”€β”€ amr_analytics.py       # AMR analysis engine (CLSI compliant)
β”‚   β”œβ”€β”€ amr_data_quality.py    # AMR-specific quality assessment
β”‚   β”œβ”€β”€ amr_interface.py       # AMR analytics interface
β”‚   β”œβ”€β”€ enhanced_amr_interface.py  # Enhanced AMR interface
β”‚   β”œβ”€β”€ app_config.py          # Configuration management
β”‚   β”œβ”€β”€ app_settings.py        # Enhanced settings management
β”‚   β”œβ”€β”€ ast_detector.py        # AST data type detection
β”‚   β”œβ”€β”€ cache_manager.py       # Advanced caching system
β”‚   β”œβ”€β”€ column_mapper.py       # Intelligent column mapping
β”‚   β”œβ”€β”€ column_utils.py        # Column utilities
β”‚   β”œβ”€β”€ data_profiler.py       # Data profiling and analysis
β”‚   β”œβ”€β”€ data_quality.py        # Data quality assessment
β”‚   β”œβ”€β”€ error_handler.py       # Error handling system
β”‚   β”œβ”€β”€ excel_exporter.py      # Multi-format export
β”‚   β”œβ”€β”€ file_handler.py        # File processing
β”‚   β”œβ”€β”€ file_merger.py         # File merging logic (with sheet selection)
β”‚   β”œβ”€β”€ glass_standardizer.py  # GLASS format standardization
β”‚   β”œβ”€β”€ glass_wizard.py        # GLASS preparation wizard
β”‚   β”œβ”€β”€ whonet_standardizer.py # WHONET format standardization
β”‚   β”œβ”€β”€ whonet_wizard.py       # WHONET preparation wizard
β”‚   β”œβ”€β”€ helpers.py             # Helper functions
β”‚   β”œβ”€β”€ logger.py              # Logging system
β”‚   β”œβ”€β”€ performance_monitor.py # Performance monitoring
β”‚   β”œβ”€β”€ production_error_handler.py  # Production error handling
β”‚   β”œβ”€β”€ production_logger.py   # Production logging
β”‚   β”œβ”€β”€ schema_analyzer.py     # Schema analysis
β”‚   β”œβ”€β”€ security.py            # Security validation
β”‚   β”œβ”€β”€ session_manager.py     # Session state management
β”‚   β”œβ”€β”€ transformer.py         # Data transformation
β”‚   β”œβ”€β”€ ui_components.py       # UI components
β”‚   β”œβ”€β”€ ui_validator.py        # UI validation
β”‚   β”œβ”€β”€ user_feedback.py       # Enhanced user feedback system
β”‚   └── validator.py           # Validation logic
β”‚
β”œβ”€β”€ scripts/                    # Deployment scripts
β”‚   β”œβ”€β”€ deploy.bat             # Windows deployment script
β”‚   └── deploy.sh              # Linux/macOS deployment script
β”‚
β”œβ”€β”€ docs/                       # Documentation
β”‚   └── PRODUCTION_GUIDE.md    # Production deployment guide
β”‚
└── deployment/                 # Deployment documentation
    └── README.md              # Deployment guide

πŸ”§ Usage

Single File Workflow

  1. Upload: Select and upload your data file (CSV, Excel)
  2. Analyze: Review data structure and quality metrics
  3. Map: Configure column mappings to target schema (optional)
  4. Transform: Apply data cleaning and standardization
  5. Validate: Verify data quality and completeness
  6. Export: Download processed data in your preferred format

Multiple File Workflow (with Excel Sheet Selection)

  1. Upload: Select multiple files for merging
  2. Select Sheets: For Excel files, choose which sheet to merge from each file
  3. Validate: Review file structures and compatibility
  4. Map: Configure column mappings between files (shared mapping across files)
  5. Merge: Combine files one at a time with intelligent data handling
  6. Audit Duplicates: Review and decide on duplicate row handling
  7. Review: Analyze merge statistics and data quality
  8. Export: Download merged dataset

GLASS/WHONET Preparation Wizards

  1. Choose Wizard: Select GLASS or WHONET preparation wizard
  2. Upload Data: Upload your AMR data file
  3. Follow Steps: Complete the guided step-by-step process
  4. Review Quality: Check comprehensive data quality assessment
  5. Apply Fixes: Use auto-fix options if needed
  6. Export: Download your standardized, submission-ready data

πŸ› οΈ Configuration

The application uses a centralized configuration system:

  • App Settings: File size limits, memory usage, processing options
  • UI Settings: Theme, layout, display preferences
  • Data Processing: Chunk sizes, optimization settings
  • Merging: Similarity thresholds, mapping preferences, sheet selection
  • Export: Default formats, compression options

Environment Variables

For production deployment, set these environment variables:

ENVIRONMENT=production
SECRET_KEY=your-secret-key-here
HOST=0.0.0.0
PORT=8501
LOG_LEVEL=INFO
MAX_FILE_SIZE_MB=100

πŸ“Š Data Quality Metrics

  • Completeness: Percentage of non-null values
  • Consistency: Data format and value consistency
  • Accuracy: Data accuracy validation
  • Validity: Data validity checks
  • Uniqueness: Duplicate detection and analysis
  • AMR-Specific: Organism name standardization, antimicrobial result validation, GLASS/WHONET compliance

πŸš€ Deployment

Streamlit Cloud

  1. Push code to GitHub
  2. Go to share.streamlit.io
  3. Connect repository: drmichaeladu/data-standardizer
  4. Set main file: app.py
  5. Deploy!

Docker

docker-compose up -d

Production Server

# Linux/macOS
./deploy_production.sh

# Windows
scripts\deploy.bat

πŸ§ͺ Testing

Run the unit test suite:

pip install -r requirements.txt  # includes pytest
python -m pytest tests/ -v

Tests cover file handling, validation, column utilities, and CSV/Excel formula injection protection.

πŸ” Troubleshooting

Common Issues

  1. Python Not Found

  2. Dependencies Not Installing

    • Check internet connection
    • Try: pip install --upgrade pip
    • Run: pip install -r requirements.txt
  3. Port Already in Use

    • Windows: taskkill /f /im python.exe
    • Linux/macOS: pkill -f streamlit
    • Or use different port: streamlit run app.py --server.port 8502
  4. Virtual Environment Issues

    • Delete .venv folder and recreate
    • Ensure you have write permissions
  5. Excel File Issues

    • Ensure openpyxl and xlrd are installed
    • Check file is not corrupted
    • Try opening file in Excel first

Getting Help

  • Check the error messages in the terminal
  • Review the application logs in logs/ directory
  • Ensure all system requirements are met
  • Try running as administrator if on Windows
  • Check the Production Guide for deployment issues

πŸ“ˆ Performance

  • Memory Optimization: Automatic DataFrame optimization
  • Chunked Processing: Large file handling
  • Caching: Intelligent data caching
  • Monitoring: Real-time performance metrics
  • Sheet Selection: Efficient Excel file processing

πŸ”’ Security

  • Input Validation: All inputs are validated
  • File Upload Limits: Configurable file size restrictions
  • CSV/Excel Formula Injection Protection: Cells starting with =, +, -, @ are sanitized to prevent execution when files are opened in Excel
  • Error Information: Controlled error disclosure
  • Memory Management: Automatic cleanup
  • Security Validation: File type and content validation

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

πŸ“ž Support

For technical support or issues:

🎯 Recent Updates

Version 2.0.0 (Latest)

  • βœ… Excel Sheet Selection: Choose specific sheets from Excel files during merging
  • βœ… Shared Column Mapping: Column mappings are saved and reused across files
  • βœ… GLASS Preparation Wizard: Step-by-step guided process for GLASS submission
  • βœ… WHONET Preparation Wizard: Step-by-step guided process for WHONET import
  • βœ… Enhanced AMR Analytics: CLSI-compliant analysis with statistical validation
  • βœ… Production Ready: Comprehensive error handling, logging, and monitoring
  • βœ… Performance Optimizations: Memory management and caching improvements

Version: 2.0.0
Last Updated: February 2025
Compatibility: Python 3.8+, Windows 10+, macOS 10.14+, Linux Ubuntu 18.04+
Repository: drmichaeladu/data-standardizer

Made with ❀️ for AMR surveillance data standardization and processing


πŸ‘₯ Contributing

We welcome contributions from the community! This project is maintained by the Ghana AMR Surveillance Center team and aims to improve antimicrobial resistance data standardization across Africa.

How to Contribute

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Continuous Integration

This project uses GitHub Actions for automated testing. The CI/CD pipeline:

  • Runs automatically on every push and pull request to any branch
  • Tests multiple Python versions: 3.8, 3.9, 3.10, and 3.11
  • Executes integration tests: Validates that all modules can be imported and work together
  • Verifies production readiness: Checks dependencies, file structure, and configurations

The workflow file is located at .github/workflows/ci.yml. All tests must pass before merging pull requests.


πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages