mirror of
https://github.com/asimonson1125/Implementations-of-Probability-Theory.git
synced 2026-02-24 21:59:50 -06:00
organizational stuff
This commit is contained in:
63
timesheet/reportUpdating.py
Normal file
63
timesheet/reportUpdating.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import subprocess
|
||||||
|
import csv
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
df = pd.read_csv("timesheet.csv")
|
||||||
|
df = df.groupby("Type").sum()
|
||||||
|
|
||||||
|
timetable += "\\noindent "
|
||||||
|
for timetype in df.iloc:
|
||||||
|
timetable += f"Hours for {timetype.name}: {timetype['Duration (Hours)']}\\\\\n"
|
||||||
|
|
||||||
|
timetable += "\\textbf{Total Hours: " + str(sum(df['Duration (Hours)'].values)) + "}\\\\\n"
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
3
timesheet/timesheet.csv
Normal file
3
timesheet/timesheet.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Week,Date,Type,Duration (Hours),Description
|
||||||
|
1,08/30,Advising Meetings,1,"Stat Review Content acknowledgement, Latex overview for reports"
|
||||||
|
2,09/02,Reporting,3,"First applications of Latex for final report, created Timesheet System."
|
||||||
|
BIN
timesheet/timesheet.pdf
Normal file
BIN
timesheet/timesheet.pdf
Normal file
Binary file not shown.
42
timesheet/timesheet.tex
Normal file
42
timesheet/timesheet.tex
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
\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 Meetings & 1 & Stat Review Content acknowledgement, Latex overview for reports \\
|
||||||
|
\hline
|
||||||
|
2 & 09/02 & Reporting & 3 & First applications of Latex for final report, created Timesheet System. \\
|
||||||
|
\hline
|
||||||
|
\end{tabular}
|
||||||
|
\end{table}
|
||||||
|
\noindent Hours for Advising Meetings: 1\\
|
||||||
|
Hours for Reporting: 3\\
|
||||||
|
\textbf{Total Hours: 4}\\
|
||||||
|
% CLOSE Timesheet
|
||||||
|
|
||||||
|
\end{document}
|
||||||
Reference in New Issue
Block a user