How do I reduce code repetition by having to open a DictWriter in csv every time?
I want to reduce the code repetition by having to create a variable with a DictWriter and all he information every time I need to write in a csv file. class Example: def func1(): with open(‘filepath’, ‘w’) as file: csv_writer = DictWriter(file, fieldnames=fieldnames, lineterminator=’\n’) … def func2(): with open(‘filepath’, ‘a’) as file: csv_writer = DictWriter(file,… Read More How do I reduce code repetition by having to open a DictWriter in csv every time?