I am searching how to append a new row to CSV in Python. What I want is that the path to be predefined as a string object. I have come across this:
import csv
fields=['first','second','third']
with open(r'name', 'a') as f:
writer = csv.writer(f)
writer.writerow(fields)
what I want is something like this in modified in the above implementation
path='home/user/new.csv'
import csv
fields=['first','second','third']
with open(rpath , 'a') as f:
writer = csv.writer(f)
writer.writerow(fields)
I can't seem to do it because of the letter r appearing in argument besides path. Can anybody guide on how to do it?