Skip to content

New header row added to CSV each time the script is run #3

Open
@DanOBrien

Description

@DanOBrien

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions