Skip to content

geacomputing/automated.word

Repository files navigation

Automated Word Report Generation with Python

Overview

This project demonstrates how to generate dynamic Word reports programmatically using Python, combining:

  • Real-time data fetching from APIs (e.g., cryptocurrency prices)
  • Local Git repository logs for version tracking
  • Synthetic experimental data read from Excel files
  • Automatic plotting with matplotlib
  • Structured Word document creation with python-docx

The goal is to create a fully automated, dynamic report that can be generated with a single script run.


Folder Structure

├───data
│ └───Lab_results
│ └───experiment1 # Synthetic experiment Excel files
├───images # Generated figures are stored here
├───Python # Optional Python scripts
├───reports # Generated Word reports saved here
└───utils
└───generate_Sinthetic_data # Script to generate synthetic Excel data
  • data/Lab_results/experiment1: Contains multiple synthetic Excel files (.xlsx) representing different experiments.
  • images/: Stores all generated plots (cryptocurrency, synthetic experiments). Plots are not deleted and can be reused.
  • reports/: Stores the final Word report generated by the main Python script.
  • utils/generate_Sinthetic_data: Python script to generate synthetic datasets with Clean, Lower, and Upper signals.

Features

  1. Dynamic Real-Time Data

    • Fetches Bitcoin prices for the last N days from the CoinGecko API.
    • Generates plots with clean, readable x-axis labels.
    • Inserts plots and tables in the Word document with proper captions.
  2. Git Repository Versioning

    • Reads the last N commits from a local Git repository.
    • Creates a table in the Word report with commit author, date, and message.
    • Adds a descriptive caption for clarity.
  3. System Information

    • Captures and documents:
      • Current user
      • Operating system and version
      • Machine name / hostname
      • Architecture
      • Python version
      • CPU / processor
  4. Synthetic Experimental Data Integration

    • Reads multiple Excel files in data/Lab_results/experiment1.
    • Each file contains three signals:
      • Clean Signal: Ideal signal without noise
      • Lower Signal: Clean minus synthetic noise
      • Upper Signal: Clean plus synthetic noise
    • Generates a plot for each experiment and inserts it into the report.
    • Adds a figure caption and a slightly varying descriptive paragraph (dynamic “Lorem ipsum” style text).
  5. Automated Word Document Formatting

    • Sections, headings, and captions are added programmatically.
    • Page breaks separate main sections and experiments.
    • Captions are centered and follow a consistent style.

Prerequisites

  • Python 3.10+ (or compatible version)
  • Conda environment: see docx_environment.yml
    • Install the environment:
      conda env create -f docx_environment.yml
    • Activate the environment:
      conda activate docx
  • Required packages (included in docx_environment.yml):
    • python-docx
    • matplotlib
    • numpy
    • pandas
    • requests
    • openpyxl (for Excel read/write)

Usage Instructions

  1. Generate Synthetic Data (if not already present):
    python utils/generate_Sinthetic_data/generate_synthetic_data.py

About

Testing python docx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages