FRET/state2gantt/plot_gantt.py

29 lines
783 B
Python

import plotly.figure_factory as ff
import plotly.express as px
import pandas as pd
import sys
def create_gantt_chart(csv_file):
# Read the CSV file
df = pd.read_csv(csv_file)
df.sort_values(by='prio', inplace=True, ascending=False)
# Prepare the data for the Gantt chart
gantt_data = [
dict(Task=row['name'], Start=row['start'], Finish=row['end'], Priority=row['prio'])
for _, row in df.iterrows()
]
# Create the Gantt chart
fig = ff.create_gantt(gantt_data, group_tasks=True)
# Show the Gantt chart
fig.write_html("plot.html")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <csv_file>")
sys.exit(1)
csv_file = sys.argv[1]
create_gantt_chart(csv_file)