Esempio n. 1
0
    def _parse_csv(self, file_name: str, delimiter: str):
        """
        Parses a CSV file and fills out two lists with column headers and data
        respectively.

        :param file_name: Absolute path to a CSV file.
        :param delimiter: Which delimiter is used in the CSV file.

        :raises FileNotFoundError: If the supplied file wasn't found.
        :raises OSError: If the supplied file couldn't be opened for reading.
        """
        if not os.path.isfile(file_name):
            raise FileNotFoundError()

        with open(file_name, "r", encoding="utf-8") as fin:

            reader = csv.DictReader(fin)
            for row in reader:
                house = House.from_dictionary(row)
                self.houses.append(house)