Did I find the right examples for you? yes no

All Samples(30)  |  Call(30)  |  Derive(0)  |  Import(0)
Determines the type of every item in the value list or dictionary,
then consolidates that into a single output type.  This is used to 
determine what type to convert an entire field into - often within
a database.

Input 
 - a list or dictionary of strings

Output:
 - a single value what type the data can be safetly converted into.(more...)

        def get_field_type(values):
    """ Determines the type of every item in the value list or dictionary,
        then consolidates that into a single output type.  This is used to 
        determine what type to convert an entire field into - often within
        a database.

        Input 
         - a list or dictionary of strings

        Output:
         - a single value what type the data can be safetly converted into.

        Types identified (and returned) include:
          - unknown
          - string
          - integer
          - float
          - timestamp

        Test Coverage:
          - complete via test harness
    """
    type_freq  = collections.defaultdict(int)

    # count occurances of each type:
    for key in values:
        i = _get_type(key)
        if i != 'unknown':                   # NOTE: unknown is filtered out
            try:                             # values is a dict
                type_freq[i] += values[key]
            except TypeError:                # values is a list
                type_freq[i] += 1
    type_list = type_freq.keys()

    # try simple rules:
    result = _get_field_type_rule(type_list)
    if result:
        return result

    # try probabilities:
    result = _get_field_type_probability(type_freq)
    return (result or 'unknown')
        


src/d/a/datagristle-0.56/gristle/field_determinator.py   datagristle(Download)
                                                            max_items)
 
            self.field_types[f_no]  = typer.get_field_type(self.field_freqs[f_no])
            if field_types_overrides:
                for col_no in field_types_overrides:

src/d/a/DataGristle-HEAD/gristle/field_determinator.py   DataGristle(Download)
                                                            max_items)
 
            self.field_types[f_no]  = typer.get_field_type(self.field_freqs[f_no])
            if field_types_overrides:
                for col_no in field_types_overrides:

src/d/a/datagristle-0.56/gristle/tests/test_field_type.py   datagristle(Download)
    def test_get_field_type_basics(self):
        assert mod.get_field_type(self.type_0a) == 'unknown'
        assert mod.get_field_type(self.type_0b) == 'unknown'
        assert mod.get_field_type(self.type_1a) == 'string'
        assert mod.get_field_type(self.type_1b) == 'integer'
        assert mod.get_field_type(self.type_2a) == 'string'

src/d/a/DataGristle-HEAD/gristle/tests/test_field_type.py   DataGristle(Download)
    def test_get_field_type_basics(self):
        assert mod.get_field_type(self.type_0a) == 'unknown'
        assert mod.get_field_type(self.type_0b) == 'unknown'
        assert mod.get_field_type(self.type_1a) == 'string'
        assert mod.get_field_type(self.type_1b) == 'integer'
        assert mod.get_field_type(self.type_2a) == 'string'