commit 5755737fc254bb6b09364efeb8b81617230d2af8 Author: Andrew Simonson Date: Mon Sep 2 10:39:15 2024 -0400 timesheet setup diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e7225c --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +## Core latex/pdflatex auxiliary files: +**/*.aux +**/*.lof +**/*.log +**/*.lot +**/*.fls +**/*.out +**/*.toc +**/*.fmt +**/*.fot +**/*.cb +**/*.cb2 +**/*.lb +**/*.fdb_latexmk +**/*.gz \ No newline at end of file diff --git a/Independent Study Proposal.docx b/Independent Study Proposal.docx new file mode 100644 index 0000000..6782ba0 Binary files /dev/null and b/Independent Study Proposal.docx differ diff --git a/reportUpdating.py b/reportUpdating.py new file mode 100644 index 0000000..ac81bea --- /dev/null +++ b/reportUpdating.py @@ -0,0 +1,54 @@ +import subprocess +import csv +import time + +def compile_latex(latex_file): + try: + # Run the pdflatex command to compile the LaTeX file + subprocess.run(['pdflatex', latex_file], check=True) + print(f'Successfully compiled {latex_file}') + except subprocess.CalledProcessError as e: + print(f'Error compiling {latex_file}: {e}') + +def timesheet2Tex(): + with open("timesheet.tex", 'r') as f: + lines = f.readlines() + timesheetStart = findIn(lines, "% OPEN Timesheet") + timesheetStop = findIn(lines, "% CLOSE Timesheet") + + timetable = csv2Table("timesheet.csv") + + with open("timesheet.tex", 'w') as f: + f.write(''.join(lines[:timesheetStart+1]) + timetable + ''.join(lines[timesheetStop:])) + +def csv2Table(inFile): + with open(inFile, 'r') as f: + reader = csv.reader(f) + rows = list(reader) + + out = "\\begin{table}[h!]\n\\centering\n" + out += "\\begin{tabular}[t]{|" + " c | c | c | c | p{6cm} |}\n" + out += "\\hline\n" + + for row in rows: + # Escape special LaTeX characters + row = [cell.replace('&', '\\&') for cell in row] + out += " & ".join(row) + " \\\\\n" + out += "\\hline\n" + + out += "\\end{tabular}\n\\end{table}\n" + return out + +def findIn(arr, target): + for i, s in enumerate(arr): + if target in s: + return i + return -1 + +if __name__ == "__main__": + timesheet2Tex() + compile_latex('timesheet.tex') + + # latex makes all kinds of files :( + subprocess.run(['rm -f *.aux *.log *.fdb_latexmk *.fls *.gz'], check=True, shell=True) + diff --git a/timesheet.csv b/timesheet.csv new file mode 100644 index 0000000..fd1acb2 --- /dev/null +++ b/timesheet.csv @@ -0,0 +1,2 @@ +Week,Date,Type,Duration (Hours),Description +1,08/30,Advising meeting,1,"Stat Review Content acknowledgement, Latex overview for reports" \ No newline at end of file diff --git a/timesheet.pdf b/timesheet.pdf new file mode 100644 index 0000000..0d34baa Binary files /dev/null and b/timesheet.pdf differ diff --git a/timesheet.tex b/timesheet.tex new file mode 100644 index 0000000..7c2e0e0 --- /dev/null +++ b/timesheet.tex @@ -0,0 +1,37 @@ +\documentclass{article} +\usepackage{blindtext} +\usepackage[a4paper, total={6in, 8in}]{geometry} +\nofiles + +\begin{document} + +\begin{titlepage} +\begin{center} + +\Large{\textbf{Implementations of Probability Theory}}\\ + +\rule{14cm}{0.05cm}\\ \vspace{.5cm} + +\Large{Independent Study Timesheet}\\ + +\large{Compiled on: \today}\\ + +\end{center} +\end{titlepage} + +\newpage + +% OPEN Timesheet +\begin{table}[h!] +\centering +\begin{tabular}[t]{| c | c | c | c | p{6cm} |} +\hline +Week & Date & Type & Duration (Hours) & Description \\ +\hline +1 & 08/30 & Advising meeting & 1 & Stat Review Content acknowledgement, Latex overview for reports \\ +\hline +\end{tabular} +\end{table} +% CLOSE Timesheet + +\end{document} \ No newline at end of file