I am trying to write data in a file. Here is how I proceed.
values = [45, 67, 39]
with open(os.path.join(path_class, r'first_file.csv'), 'a') as f:
writer = csv.writer(f)
writer.writerow(values)
But I would like to have a variable at first_file.csv position.
My problem is here with open(os.path.join(path_class, r'file_name.csv')
So I would like to have something like:
list_of_file = ['first_file.csv', 'second_file.csv']
for i in range(0, len(list_of_file):
with open(os.path.join(path_class, r+list_of_file[i]), 'a') as f:
writer = csv.writer(f)
writer.writerow(values)
How could I do that
Thank you for taking your time to answer my question.