How do I add headers to row one in a csv?
My solution currently appends everything
Something like: writer.writerow(['DataA', 'DataB', 'DataC', 'DATA D'])[0]
I feel like there an easy way of doing this and I'm overlooking the obvious.
I've looked at a lot of examples online but am still struggling as to how you can easily do this in a csv.
As an example lets say I wanted to scrape data of SO - load up selenium, write that into four columns and do this for 20 pages. I'd want to write the headers to row 1 each time and then append the scraped data
with open('C:\\fa.csv', 'a+', newline='', encoding="utf-8") as outfile:
writer = csv.writer(outfile)
writer.writerow(['DataA', 'DataB', 'DataC', 'DataD'])
for row in zip(ZAW_text, RESULTS1, RESULTS):
writer.writerow(row)
#writer.writerows({'Date': row[0], 'temperature 1': row[1], 'temperature 2': 0.0} for row in writer)
print(row)