Example #1
0
File: row.py Project: rainiraj/atk
    def __init__(self, schema, data=None):
        """
        Expects schema to as list of tuples
        """

        # Can afford a richer object since it will be reused per row, with more init up front to save calculation
        standardized_schema = [(name, valid_data_types.get_from_type(t)) for name, t in schema]
        self.__schema_dict = OrderedDict(standardized_schema)
        self.__data = [] if data is None else data  # data is an array of strings right now
        self.__dtypes = self.__schema_dict.values()
        self.__indices_dict = dict([(k, i) for i, k, in enumerate(self.__schema_dict.keys())])
        self.__dtype_constructors = [valid_data_types.get_constructor(t) for t in self.__dtypes]
Example #2
0
    def __init__(self, schema, data=None):
        """
        Expects schema to as list of tuples
        """

        # Can afford a richer object since it will be reused per row, with more init up front to save calculation
        standardized_schema = [(name, valid_data_types.get_from_type(t)) for name, t in schema]
        self.__schema_dict = OrderedDict(standardized_schema)
        self.__data = [] if data is None else data  # data is an array of strings right now
        self.__dtypes = self.__schema_dict.values()
        self.__indices_dict = dict([(k, i) for i, k, in enumerate(self.__schema_dict.keys())])
        self.__dtype_constructors = [valid_data_types.get_constructor(t) for t in self.__dtypes]
Example #3
0
 def _validate(self):
     validated_schema = []
     for field in self.schema:
         name = field[0]
         if not isinstance(name, basestring):
             raise ValueError("First item in CSV schema tuple must be a string")
         try:
             data_type = valid_data_types.get_from_type(field[1])
         except ValueError:
             raise ValueError("Second item in CSV schema tuple must be a supported type: " + str(valid_data_types))
         else:
             validated_schema.append((name, data_type))
     self.schema = validated_schema
Example #4
0
 def _validate(self):
     validated_schema = []
     for field in self.schema:
         name = field[0]
         if not isinstance(name, basestring):
             raise ValueError("First item in schema tuple must be a string")
         try:
             data_type = valid_data_types.get_from_type(field[1])
         except ValueError:
             raise ValueError("Second item in schema tuple must be a supported type: " + str(valid_data_types))
         else:
             validated_schema.append((name, data_type))
     self.schema = validated_schema
Example #5
0
File: column.py Project: xoltar/atk
 def __init__(self, frame, name, data_type):
     self.name = name
     self.data_type = valid_data_types.get_from_type(data_type)
     self._frame = frame
Example #6
0
 def __init__(self, frame, name, data_type):
     self.name = name
     self.data_type = valid_data_types.get_from_type(data_type)
     self._frame = frame