import json from datetime import datetime def generate_metadata_table(trip_report): metadata_table = """
Attribute | Value |
---|---|
Chemical | {} |
Tester | {} |
Dosage | {} |
Tolerance | {} |
Cross-Tolerance | {} |
Timestamp | Elapsed Time | Notes |
---|---|---|
{} | {} | {} |
Report submitted at: {}
Static HTML generated at: {}
""".format(metadata_table, trip_report_table, submit_date, generation_date) return html_report def save_html_report(html_report, destination_path): with open(destination_path, 'w') as html_file: html_file.write(html_report) print("HTML report saved to {}.".format(destination_path)) if __name__ == "__main__": json_path = input("Enter path to JSON report: ") destination_path = input("Enter path for destination HTML file: ") with open(json_path, 'r') as json_file: trip_report = json.load(json_file) html_report = generate_html_report(trip_report) save_html_report(html_report, destination_path)