0

Is there a recommended way to add a ".csv" extension, to a file's name or path, which you want to export as a csv?

I achieved it directly and naively, and I wonder if there is another way to make it more elegant.

My code:

def get_file_path (csv_name, file_path, file_type = ".csv"):

    cwd = os.getcwd()
    file_path = os.path.join(cwd, csv_name + file_type)

    return file_path
Amit S
  • 225
  • 6
  • 16

0 Answers0