import csv


class CSVReporter:
    """Creates CSV reports."""

    def __init__(self, filename):
        # TODO: set filepath for CSV
        self.filename = filename

        pass

    def write_report(self, results, invalid_only=True):
        """Writes results to a CSV file.

        Args:
            results (list): A list of dictionaries containing information about validation results.
            invalid_only (boolean): Only report on invalid results.
        """

        with open(self.filename) as f:
            fieldnames = [
                "title",
                "publish",
                "resource",
                "extent",
                "date",
                "language",
                "repository",
                "creator",
                "scope",
                "restrictions"]
            writer = csv.DictWriter(
                f, fieldnames=fieldnames)
            writer.writeheader()
            writer.writerows(results)
        pass

@@ -88,19 +88,33 @@
 filename
+, filemode=%22w%22
 ):%0A
-
         
@@ -175,25 +175,24 @@
 ilename%0A
-%0A
         
 pass%0A%0A  
@@ -183,20 +183,40 @@
         
-pass
+self.filemode = filemode
 %0A%0A    de
@@ -533,16 +533,31 @@
 filename
+, self.filemode
 ) as f:%0A
@@ -967,16 +967,16 @@
 eader()%0A
+
         
@@ -1009,17 +1009,4 @@
 ts)%0A
-        pass%0A

add filemode