def _get_dialect_quoting(self, dialect):
        """ Since Sniffer tends to default to QUOTE_MINIMAL we're going to try to
            get a more accurate guess.  In the event that there's an extremely
            consistent set of data that is either all quoted or not quoted at
            all we will return that appropriate value.
        """

        # total_field_cnt has a key for each number of fields found in a
        # record, and a value that indicates how often this total was found
        total_field_cnt  = collections.defaultdict(int)

        # quoted_field_cnt has a key for each number of quoted fields found
        # in a record, and a value that indicates how often this total was
        # found.
        quoted_field_cnt = collections.defaultdict(int)

        rec_cnt   = 0
        for rec in fileinput.input(self.fqfn):
            fields = rec[:-1].split(dialect.delimiter)
            total_field_cnt[len(fields)] += 1

            quoted_cnt = 0
            for field in fields:
                if len(field) >= 2:
                    if field[0] == '"' and field[-1] == '"':
                        quoted_cnt += 1
            quoted_field_cnt[quoted_cnt] += 1

            if rec_cnt > 1000:
                break
        fileinput.close()

        # "Exact" scenario: simplest and most clear in which we have no confusing
        # data, every record has the same number of fields and either all are quoted
        # or none are.  This is handled specially since it's often screwed up 
        # by the Sniffer, and it's a common situation.
        if (len(total_field_cnt) == 1
        and len(quoted_field_cnt) == 1):
            if total_field_cnt[0] == quoted_field_cnt [0]:
                return csv.QUOTE_ALL
            elif quoted_field_cnt[0] == 0:
                return csv.QUOTE_NONE

        # "Almost Exact" scenario: almost the same as with the exact scenario
        # above, but in this case it allows for a few malformed records.
        # The numbers must be nearly identical - with both the most common field
        # count and most common quoted field count occuring 95% of the time.
        common_field_key, common_field_pct               = \
                   comm.get_common_key(total_field_cnt)
        common_quoted_field_key, common_quoted_field_pct = \
                   comm.get_common_key(quoted_field_cnt)

        if (common_field_pct > .95 
        and .95 > common_quoted_field_pct):
            if common_field_key ==  common_quoted_field_key:
                return csv.QUOTE_ALL
            else:
                return csv.QUOTE_NONE

        # Final scenario - we can't make much of an improvement, it's probably
        # either QUOTED_MINIMAL or QUOTED_NONNUMERIC.  Sniffer probably labeled
        # it QUOTED_MINIMAL.
        return dialect.quoting
dataset/ETHPy150Open kenfar/DataGristle/gristle/file_type.py/FileTyper._get_dialect_quoting/swapped operands of `>`