You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB
Python

import json
from datetime import datetime
def generate_raw_text(trip_report):
raw_text += f"# Metadata\n"
raw_text += f"Chemical: {trip_report['chemical']}\n"
raw_text += f"Tester: {trip_report['tester']}\n"
raw_text += f"Dosage: {trip_report['dosage']}\n"
raw_text += f"Tolerance: {trip_report['tolerance']}\n"
raw_text += f"Cross-Tolerance: {trip_report['cross_tolerance']}\n\n"
raw_text += "# Report\n"
for entry in trip_report['entries']:
raw_text += f"{entry['timestamp']} ({entry['elapsed_time']}) {entry['notes']}\n"
raw_text += f"\nReport generated on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n"
raw_text += f"Submit date: {trip_report['submit_date']}\n"
return raw_text
def save_raw_text(raw_text, destination_path):
with open(destination_path, 'w') as txt_file:
txt_file.write(raw_text)
print(f"Raw text saved to {destination_path}.")
if __name__ == "__main__":
json_path = input("Enter path to JSON report: ")
destination_path = input("Enter path for destination TXT file: ")
with open(json_path, 'r') as json_file:
trip_report = json.load(json_file)
raw_text = generate_raw_text(trip_report)
save_raw_text(raw_text, destination_path)