I have been working on a project for a little bit now. This project I am opening a CSV file for writing. Here is the code:
def process_form_in_csv(self, order_id, order_date, order_fees):
file_exists = os.path.isfile(self.SALES_SHEET)
with open(self.SALES_SHEET, 'ab') as csvfile:
fieldnames = ['Date','Order ID','Fee']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
if not file_exists:
writer.writeheader()
writer.writerow({'Date': order_date,
'Order ID': order_id,
'Seller Fee': order_fees,
})
csvfile.close()
This code works, but whenever I rerun the program the first line will be carried down the row and placed 3 cells over from where it should be. If I delete cells (in Excel) they remain. I don't know what is going on. Attached is an image of what the "blank" csv looks like.