warn_transformer/transformers/wi.py
def handle_amendments(
        self, row_list: typing.List[typing.Dict]
    ) -> typing.List[typing.Dict]:
        """Remove amended filings from the provided list of records.

        Args:
            row_list (list): A list of clean rows of data.

        Returns: A list of cleaned data, minus amended records.
        """
        amendments_count = len([r for r in row_list if r["is_amendment"] is True])
        logger.debug(f"{amendments_count} amendments in {self.postal_code}")

        # Loop through all the rows
        ancestor_list = []
        for i, row in enumerate(row_list):
            # If the current row is amended ...
            if row["is_amendment"]:
                # Get the previous record
                previous_index = i - 1
                previous_record = row_list[previous_index]

                # Are the first five characters of the company name found?
                similar_name = (
                    row["company"][:5].lower() in previous_record["company"].lower()
                )

                # If not, it's not an obvious ancestor
                if not similar_name:
                    logger.debug(f"No ancestor found for {row['company']}")
                    continue

                # If the name is similar, the previous record should be struck
                # We'll mark it by adding its hash_id to our list
                ancestor_list.append(previous_record["hash_id"])

        # Cut all of the ancestor records
        logger.debug(f"{len(ancestor_list)} ancestors removed")
        amended_list = [r for r in row_list if r["hash_id"] not in ancestor_list]

        # Return the rows we want to keep
        return amended_list
Remove amended filings from the provided list of records.

        Args:
            row_list (list): A list of clean rows of data.

        Returns: A list of cleaned data, minus amended records.
        
Remove amended filings from the provided list of records.
Remove amended filings from the provided list of records .
def handle_amendments(
        self, row_list: typing.List[typing.Dict]
    ) -> typing.List[typing.Dict]:
        amendments_count = len([r for r in row_list if r["is_amendment"] is True])
        logger.debug(f"{amendments_count} amendments in {self.postal_code}")
        ancestor_list = []
        for i, row in enumerate(row_list):
            if row["is_amendment"]:
                previous_index = i - 1
                previous_record = row_list[previous_index]
                similar_name = (
                    row["company"][:5].lower() in previous_record["company"].lower()
                )
                if not similar_name:
                    logger.debug(f"No ancestor found for {row['company']}")
                    continue
                ancestor_list.append(previous_record["hash_id"])
        logger.debug(f"{len(ancestor_list)} ancestors removed")
        amended_list = [r for r in row_list if r["hash_id"] not in ancestor_list]
        return amended_list
def handle_amendments ( self , row_list : typing . List [ typing . Dict ] ) -> typing . List [ typing . Dict ] : amendments_count = len ( [ r for r in row_list if r [ "is_amendment" ] is True ] ) logger . debug ( f"{amendments_count} amendments in {self.postal_code}" ) ancestor_list = [ ] for i , row in enumerate ( row_list ) : if row [ "is_amendment" ] : previous_index = i - 1 previous_record = row_list [ previous_index ] similar_name = ( row [ "company" ] [ : 5 ] . lower ( ) in previous_record [ "company" ] . lower ( ) ) if not similar_name : logger . debug ( f"No ancestor found for {row['company']}" ) continue ancestor_list . append ( previous_record [ "hash_id" ] ) logger . debug ( f"{len(ancestor_list)} ancestors removed" ) amended_list = [ r for r in row_list if r [ "hash_id" ] not in ancestor_list ] return amended_list
Remove amended filings from the provided list of records.
Remove amended filings from the provided list of records .
"""Remove amended filings from the provided list of records.

        Args:
            row_list (list): A list of clean rows of data.

        Returns: A list of cleaned data, minus amended records.
        """ # Loop through all the rows # If the current row is amended ... # Get the previous record # Are the first five characters of the company name found? # If not, it's not an obvious ancestor # If the name is similar, the previous record should be struck # We'll mark it by adding its hash_id to our list # Cut all of the ancestor records # Return the rows we want to keep
self
row_list
typing.List[typing.Dict]
A list of clean rows of data.
A list of clean rows of data .