I am a Python beginner. I made a script which, after doing what it is supposed to do, creates a file called "report.csv" with some datas I need.
This is how that part of code looks like:
with open('report.csv'), 'x', newline='') as report_file:
report_writer = csv.writer(report_file)
report_writer.writerows(array_i_have_to_write_in_csv)
If report.csv does not exists, everything works perfectly. Otherwise, it throws FileExistsError exception.
I'd like to handle it naming files with a progressive number, like "report-001.csv", "report-002.csv", etc. but how can I do that?
Thanks