Skip to content
Snippets Groups Projects
Commit b6d5fbc3 authored by DIANE's avatar DIANE
Browse files

report

parent 75da33af
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,6 @@ import subprocess
from pathlib import Path
import os
import pandas as pd
from config.config import pdflatex_path
import zipfile
def report(*args):
to_report=[]
......@@ -67,7 +65,7 @@ def report(*args):
"""
if 'model' in to_report:
latex_report += r"""\subsection{Data Visualization}
latex_report += r"""\subsection*{Data Visualization}
Here we have a sub-heading. There is no blank line after the sub-heading. You can have one level of subheadings but not a third i.e. you cannot have Section 1.1.1 as a subheading.
\begin{center}
......@@ -110,8 +108,7 @@ def report(*args):
"""
latex_report += r"""
\begin{center}
Model performance
""" + df1.to_latex(escape=True) + r"""
\end{center}
"""
latex_report += r"""
......@@ -425,35 +422,25 @@ def report(*args):
# latex_report = report('sample', 'predict',)
def compile_latex():
# path to pdflatex imported from config/config.py
# path to pdflatex
# pdflatex_path = Path("C:/Users/maimouni/AppData/Local/Programs/MiKTeX/miktex/bin/x64/")
from config.config import pdflatex_path
filename_path = Path("Report/")
filename = 'report.tex'
# run pdflatex with bibtex compilation (2nd run)
for i in range(4):
print(i)
if i == 1:
proc = subprocess.Popen([pdflatex_path / 'bibtex.exe', filename[:-4]], cwd = filename_path)
proc.communicate()
else:
proc = subprocess.Popen([pdflatex_path / 'pdflatex.exe', filename], cwd = filename_path)
proc.communicate()
os.rename(filename_path / 'report.pdf', filename_path / 'figures' / 'report.pdf')
# remove pdflatex compilation files
extensions = ['.log', '.aux', '.bbl', '.blg', '.out', '.tex']
for ext in extensions:
os.unlink(str(filename_path / filename[:-4]) + ext)
extensions = ['.log', '.aux', '.bbl', '.blg', '.out']
#for ext in extensions:
#os.unlink(str(filename_path / filename[:-4]) + ext)
# open the report
# proc = subprocess.Popen([str(filename[:-4]) + '.pdf'], cwd = filename_path / 'figures', shell=True)
# proc.communicate()
folder_path = Path('Report/figures')
zip_path = Path('Report/')
with zipfile.ZipFile(zip_path / 'archive_zipfile.zip', 'w', compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
for root, dirs, files in os.walk(folder_path):
for file in files:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, folder_path)
zf.write(file_path, arcname)
proc = subprocess.Popen([str(filename[:-4]) + '.pdf'], cwd = filename_path, shell=True)
proc.communicate()
# compile_latex()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment