Closed jschalk closed 3 days ago
having problems with RoadBridge.reveal_inx() because of roadnode/roadunit difference. Obvious solution is to create UnitRoadBridge and NodeRoadBridge. And then using otx_label, inx_label and otx_road, otx_road Going to close this ticket for now. Leaving thecode in the codebase because probably will have to come back to this.
[ ] replace all excel writes with update_or_create_excel_sheet
def update_or_create_sheet(file_path, sheet_name, dataframe):
"""
Updates or creates an Excel sheet with a specified DataFrame.
Args:
- file_path (str): The path to the Excel file.
- sheet_name (str): The name of the sheet to update or create.
- dataframe (pd.DataFrame): The DataFrame to write to the sheet.
"""
# Check if the file exists
if not os.path.exists(file_path):
# If file does not exist, create it with the specified sheet
with pd.ExcelWriter(file_path, engine='xlsxwriter') as writer:
dataframe.to_excel(writer, sheet_name=sheet_name, index=False)
print(f"File '{file_path}' created with sheet '{sheet_name}'.")
return
# If the file exists, check for the sheet
try:
with pd.ExcelWriter(file_path, engine='openpyxl', mode='a', if_sheet_exists='replace') as writer:
dataframe.to_excel(writer, sheet_name=sheet_name, index=False)
print(f"Sheet '{sheet_name}' in file '{file_path}' replaced successfully.")
except Exception as e:
print(f"An error occurred: {e}")