Skip to content
Snippets Groups Projects
Commit fb4ea57f authored by Sven-Ove Hänsel's avatar Sven-Ove Hänsel
Browse files

rename created pdfs

parent 278ec19f
No related branches found
No related tags found
No related merge requests found
File deleted
File deleted
File deleted
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
{ {
"cell_type": "code", "cell_type": "code",
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> fafe180 (rename created pdfs)
"execution_count": 10, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
...@@ -73,8 +76,11 @@ ...@@ -73,8 +76,11 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
<<<<<<< HEAD
======= =======
>>>>>>> 166aba1 (moved a lot of eval files) >>>>>>> 166aba1 (moved a lot of eval files)
=======
>>>>>>> fafe180 (rename created pdfs)
"execution_count": 11, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
......
%% Cell type:code id: tags:
``` python
import os
import pandas as pd
import plotly.express as px
# Base directory where your CSV files are located
base_directory = r"C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments"
# Function to create a chart from a dataframe and save as PDF
def create_and_save_chart(df, file_path):
# Convert 'Time' column to datetime type for better x-axis formatting
# Ensuring the 'Time' column is recognized, accounting for potential case sensitivity
time_column = next((col for col in df.columns if col.lower() == 'time'), None)
if time_column is None:
print(f"Column 'Time' not found in {file_path}. Skipping file.")
return
df[time_column] = pd.to_datetime(df[time_column])
# Melting the dataframe to make it long-form which Plotly prefers
df_long = df.melt(id_vars=[time_column], var_name='Metric', value_name='Value')
# Creating a line chart with Plotly Express
fig = px.line(df_long, x=time_column, y='Value', color='Metric',
title='Metrics Over Time', labels={'Value': 'Metric Value', time_column: 'Time'})
# Improve layout (optional)
fig.update_layout(xaxis_title='Time',
yaxis_title='Value',
legend_title='Metric',
template='plotly_white')
# Use write_image to save the figure as a PDF, leveraging kaleido
fig.write_image(file_path, format='pdf', width=1980, height=1080)
# Traverse the directory tree
for root, dirs, files in os.walk(base_directory):
for filename in files:
if filename.endswith(".csv"):
file_path = os.path.join(root, filename)
# Read the CSV file into a DataFrame
df = pd.read_csv(file_path)
# Automatically trim column names and check for 'Time' column case sensitivity
df.columns = [col.strip() for col in df.columns] # Trim whitespace from column names
# Define the path for the PDF file
pdf_path = os.path.splitext(file_path)[0] + '.pdf'
# Create and save the chart
create_and_save_chart(df, pdf_path)
print("Charts created and saved as PDFs.")
```
%% Output
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_1500\query_logs\memgraph\2024-02-11_11-58-08_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_1500\query_logs\neo4j\2024-02-11_11-58-08_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_1500\query_logs\ongdb\2024-02-11_11-58-08_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_1500\query_logs\pg\2024-02-11_11-58-08_query_execution_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2000\query_logs\memgraph\2024-02-12_12-12-38_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2000\query_logs\neo4j\2024-02-12_12-12-38_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2000\query_logs\ongdb\2024-02-12_12-12-38_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2000\query_logs\pg\2024-02-12_12-12-38_query_execution_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2500\query_logs\memgraph\2024-02-12_20-31-09_query_execution_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2500\query_logs\neo4j\2024-02-12_20-31-09_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2500\query_logs\ongdb\2024-02-12_20-31-09_query_logs.pdf. Skipping file.
Column 'Time' not found in C:\Studium_MIN\05_Masterarbeit\thesis\ma_code\code\eval\experiments\240212_window_size_2500\query_logs\pg\2024-02-12_20-31-09_query_execution_logs.pdf. Skipping file.
Charts created and saved as PDFs.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment