I am generating a csv file in pandas using this code:
current_working_directory = os.getcwd()
path2 = 'Documents'
current_datetime = datetime.now()
filename = f"python_df_{current_datetime}.csv"
full_path = os.path.join(current_working_directory, path2, filename)
when I print(full_path)
I get the desired path, however when I run df.to_csv(full_path, index=False)
I get the file with an extra as such 'C:\Users\User\Documents\python_df_2024-07-23 16:07:08.01581.csv
which leads to the following error:
[Errno 22] Invalid argument: 'C:\Users\User\Documents\python_df_2024-07-23 16:07:08.01581.csv'
Also, I’m using a Windows machine and whilst this works fine on mac I can’t get it work on Windows.