I have the following code:
# function to truncate files
def truncate(path):
file_to_truncate = open(path, "w")
file_to_truncate.truncate()
file_to_truncate.close()
# truncate all relevant files so they are empty and new results are not written underneath another set of results
truncate(r'outputA.csv')
truncate(r'\outputB.csv')
truncate(r'outputC.csv')
truncate(r'outputD.csv')
truncate(r'outputE.csv')
truncate(r'MoutputA.csv')
truncate(r'MoutputB.csv')
truncate(r'MoutputC.csv')
truncate(r'MoutputD.csv')
truncate(r"Full Results.csv")
truncate(r'results.csv')
Is it possible to shorten this code i.e truncate all files in the directory.