import csv


def write_output_csv(output_csv_path, data, csv_type):
    """
    Accepts a dictionary of rows and writes a new CSV
    Columns should be: ID, chromosome_name, start_position, end_position, strand, padj, log2FoldChange
    """
    count = 1

    # Open a second output file and write only unique rows
    with open(output_csv_path, "w", newline="") as csv_file:
        writer = csv.writer(csv_file, delimiter="\t")

        # First row, header
        if csv_type == "diff":
            
            header = [
                "'ID'",
                "'chromosome_name'",
                "'start_position'",
                "'end_position'",
                "'strand'",
                "'padj'",
                "'log2FoldChange'",
            ]
            writer.writerow(header)

            # Prepend a unique id and write to csv
            for key, value in data.items():
                writer.writerow([count] + value)

                count += 1
        else:
            # Prepend a unique id and write to csv
            for key, value in data.items():
                writer.writerow(value)

                count += 1

    return count - 1