Any print(TO_CSV,..) call just prints the resulting string in the CSV file. So you just have to pass a format string containing the counter number in the proper .csv format that you need.