'Printing out saved CSV file path from pandas in python

I am working on a code that need to show an notification where saved csv file's path need to be printed that is obtained from Pandas df.to_csv() method.

my question is "is there any way to get the path file to generated csv file?"

Thank you. enter image description here

I am expecting some way to get saved csv file's path so that it can be in place of xxxxxxxx.



Solution 1:[1]

You can optionally add a path to DataFrame.to_csv() as per the path_or_buf argument. Simply define where you are saving the file then print this file path. For example:

path = '/User/documents/python/data.csv'
DataFrame.to_csv(path_or_buf=path)
print(path)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jda5