I have created a script which includes the below.
The idea is to go through a list of excel files (Countries) in a folder and then, if it exists already to pass through and ignore, if it does not exist then to create it. In both cases, it will then move on to the rest of the script. I want to create it this way because I do not want to overwrite the other countries files every time as there will be data dating back a few months in each file (so overwriting will lose this). I would like to just create a new file for when one new country gets added to the list.
I cannot just create a file manually, as the rest of the script takes into account all files.
if ''.join(Countries) in path:
pass
else:
for x in Countries:
workbook = xlsxwriter.Workbook(path + x)
worksheet = workbook.add_worksheet(sheetname)
FirstSheet = ([firstMes])
row = 0
col = 0
for y in (FirstSheet):
worksheet.write(row, col, y)
row += 1
workbook.close()