You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We only need to write the headers once, so if we modify the "write" block to see if this is the first time we're writing the CSV, we don't keep seeing headers added to the file when we've gone back to add new books:
if len(new_additions) > 0:
with open(filename, 'a') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=fields)
if current_ID == 1:
writer.writeheader()
for item in new_additions:
writer.writerow(item)
The text was updated successfully, but these errors were encountered:
We only need to write the headers once, so if we modify the "write" block to see if this is the first time we're writing the CSV, we don't keep seeing headers added to the file when we've gone back to add new books:
The text was updated successfully, but these errors were encountered: