I don't understand how the writer object works
how does it write to the files?
def write_files_to_csv(file_counts, output_file):
"""
Writes filename and modification counts to CSV. Identifies the file with the highest modifications.
- dictfiles: Dictionary {filename: modification count}.
- file: Base name for the output CSV file.
"""
fileOutput = 'data/file_' + file + '.csv'
rows = ["Filename", "Touches"]
fileCSV = open(fileOutput, 'w')
writer = csv.writer(fileCSV)
writer.writerow(rows)
bigcount = None
bigfilename = None
for filename, count in dictfiles.items():
rows = [filename, count]
writer.writerow(rows)
if bigcount is None or count > bigcount:
bigcount = count
bigfilename = filename
fileCSV.close()
print('The file ' + bigfilename + ' has been touched ' + str(bigcount) + ' times.')
I don't understand how the writer object works
how does it write to the files?