Calls :meth:`import_export.fields.Field.save` if ``Field.attribute``
        and ``Field.column_name`` are found in ``data``.
168979
def import_field(self, field, obj, data, is_m2m=False):
        
        if field.attribute and field.column_name in data:
            field.save(obj, data, is_m2m)
1301316
private int getTTLForColumn(Object columnTTLs, Attribute attribute)
    {
        Integer ttl = null;
        if (columnTTLs != null)
        {
            if (columnTTLs instanceof Map)
            {
                ttl = (Integer) (columnTTLs == null ? 0 : ((Map) columnTTLs).get(((AbstractAttribute) attribute)
                        .getJPAColumnName()));
            }
            else if (columnTTLs instanceof Integer)
            {
                ttl = (Integer) columnTTLs;
            }
        }
        return ttl == null ? 0 : ttl;
    }
205424
def posted_data(self, field):
        
        try:
            return self.cleaned_data[field]
        except (AttributeError, KeyError):
            return field.endswith("_export")
310416
def _saveModel(self):
        
        delimiter = self._delimiterBox.currentSelected()
        header = self._headerCheckBox.isChecked() # column labels
        if self._filename is None:
            filename = self._filenameLineEdit.text()
        else:
            filename = self._filename
        ext = os.path.splitext(filename)[1].lower()
        index = False # row labels

        encodingIndex = self._encodingComboBox.currentIndex()
        encoding = self._encodingComboBox.itemText(encodingIndex)
        encoding = _calculateEncodingKey(encoding.lower())

        try:
            dataFrame = self._model.dataFrame()
        except AttributeError as err:
            raise AttributeError('No data loaded to export.')
        else:
            print("Identifying export type for {}".format(filename))
            try:
                if ext in ['.txt','.csv']:
                    dataFrame.to_csv(filename, encoding=encoding, header=header, index=index, sep=delimiter)
                elif ext == '.tsv':
                    sep = '\t'
                    dataFrame.to_csv(filename, encoding=encoding, header=header, index=index, sep=delimiter)
                elif ext in ['.xlsx','.xls']:
                    dataFrame.to_excel(filename, encoding=encoding, header=header, index=index, sep=delimiter)
            except IOError as err:
                raise IOError('No filename given')
            except UnicodeError as err:
                raise UnicodeError('Could not encode all data. Choose a different encoding')
            except Exception:
                raise
            self.signalExportFilenames.emit(self._model._filePath, filename)
2054
def export_data(self):
        

        def export_field(value):
            """
            Export item
            """
            try:
                return value.export_data()
            except AttributeError:
                return value

        if self.__modified_data__ is not None:
            return [export_field(value) for value in self.__modified_data__]
        return [export_field(value) for value in self.__original_data__]
269232
def get_field_schema(name, field):
    """"""
    field_schema = {
        'type': 'string',
    }

    if field.label:
        field_schema['title'] = str(field.label)  # force translation

    if field.help_text:
        field_schema['description'] = str(field.help_text)  # force translation

    if isinstance(field, (fields.URLField, fields.FileField)):
        field_schema['format'] = 'uri'
    elif isinstance(field, fields.EmailField):
        field_schema['format'] = 'email'
    elif isinstance(field, fields.DateTimeField):
        field_schema['format'] = 'date-time'
    elif isinstance(field, fields.DateField):
        field_schema['format'] = 'date'
    elif isinstance(field, (fields.DecimalField, fields.FloatField)):
        field_schema['type'] = 'number'
    elif isinstance(field, fields.IntegerField):
        field_schema['type'] = 'integer'
    elif isinstance(field, fields.NullBooleanField):
        field_schema['type'] = 'boolean'
    elif isinstance(field.widget, widgets.CheckboxInput):
        field_schema['type'] = 'boolean'

    if getattr(field, 'choices', []):
        field_schema['enum'] = sorted([choice[0] for choice in field.choices])

    # check for multiple values
    if isinstance(field.widget, (widgets.Select, widgets.ChoiceWidget)):
        if field.widget.allow_multiple_selected:
            # promote to array of <type>, move details into the items field
            field_schema['items'] = {
                'type': field_schema['type'],
            }
            if 'enum' in field_schema:
                field_schema['items']['enum'] = field_schema.pop('enum')
            field_schema['type'] = 'array'

    return field_schema
151972
public void addEqualToColumn(String attribute, String colName)
    {
		// FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, colName, getAlias());
		FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, colName, getUserAlias(attribute));
        c.setTranslateField(false);
        addSelectionCriteria(c);
    }
844729
def field_definition_post_save(sender, instance, created, raw, **kwargs):
    
    model_class = instance.model_def.model_class().render_state()
    field = instance.construct_for_migrate()
    field.model = model_class
    if created:
        if hasattr(instance._state, '_creation_default_value'):
            field.default = instance._state._creation_default_value
            delattr(instance._state, '_creation_default_value')
        add_column = popattr(instance._state, '_add_column', True)
        if add_column:
            perform_ddl('add_field', model_class, field)
            # If the field definition is raw we must re-create the model class
            # since ModelDefinitionAttribute.save won't be called
            if raw:
                instance.model_def.model_class().mark_as_obsolete()
    else:
        old_field = instance._state._pre_save_field
        delattr(instance._state, '_pre_save_field')
        perform_ddl('alter_field', model_class, old_field, field, strict=True)
1285126
def columns(self):
        
        fields = [f.label for f in self.form_fields
                  if self.cleaned_data["field_%s_export" % f.id]]
        if self.cleaned_data["field_0_export"]:
            fields.append(self.entry_time_name)
        return fields
479579
def db_import(ctx, schema, uuid, object_filter, import_format, filename, all_schemata, dry):
    """"""

    import_format = import_format.upper()

    with open(filename, 'r') as f:
        json_data = f.read()
    data = json.loads(json_data)  # , parse_float=True, parse_int=True)

    if schema is None:
        if all_schemata is False:
            log('No schema given. Read the help', lvl=warn)
            return
        else:
            schemata = data.keys()
    else:
        schemata = [schema]

    from hfos import database
    database.initialize(ctx.obj['dbhost'], ctx.obj['dbname'])

    all_items = {}
    total = 0

    for schema_item in schemata:
        model = database.objectmodels[schema_item]

        objects = data[schema_item]
        if uuid:
            for item in objects:
                if item['uuid'] == uuid:
                    items = [model(item)]
        else:
            items = []
            for item in objects:
                thing = model(item)
                items.append(thing)

        schema_total = len(items)
        total += schema_total

        if dry:
            log('Would import', schema_total, 'items of', schema_item)
        all_items[schema_item] = items

    if dry:
        log('Would import', total, 'objects.')
    else:
        log('Importing', total, 'objects.')
        for schema_name, item_list in all_items.items():
            log('Importing', len(item_list), 'objects of type', schema_name)
            for item in item_list:
                item._fields['_id'] = bson.objectid.ObjectId(item._fields['_id'])
                item.save()
92680
def add_field(field, data_type = nil, options = {})
      data_type = DataType::String if data_type.nil?
      puts [":#{field}", "#{data_type.class.to_s}", "#{options.inspect}"].collect { |s| s.ljust(25) }.join if ENV['DEBUG']
      
      # Fields that do special things go here.
      if field == :timestamps
        add_field(:updated_at, :datetime)
        add_field(:created_at, :datetime)
        return true
      end

      # Add index if explicitly asked
      @indexes << field if options.delete(:index) || data_type.class.to_s == 'Hash' && data_type.delete(:index)
      @validations[field] = options.delete(:validates) if options[:validates]
      options.merge!(:field => field)    
      
      # Matches: description DataType::Paragraph, :index => true
      if data_type.is_a?(Class) && data_type.respond_to?(:migrant_data_type?)
        @columns[field] = data_type.new(options)
      # Matches: description :index => true, :unique => true
      else
        begin
          # Eg. "My field" -> String -> DataType::String
          @columns[field] = "DataType::#{data_type.class.to_s}".constantize.new(options.merge(:value => data_type))
        rescue NameError
          # We don't have a matching type, throw a warning and default to string
          puts "MIGRATION WARNING: No migration implementation for class #{data_type.class.to_s} on field '#{field}', defaulting to string..."
          @columns[field] = DataType::Base.new(options)
        end
      end
    end
326002
def export_modified_data(self):
        
        # TODO: why None? Try to get a better flag
        result = {key: None for key in self.__deleted_fields__}

        for key, value in self.__modified_data__.items():
            if key in result.keys():
                continue
            try:
                result[key] = value.export_modified_data()
            except AttributeError:
                result[key] = value

        for key, value in self.__original_data__.items():
            if key in result.keys():
                continue
            try:
                if value.is_modified():
                    result[key] = value.export_modified_data()
            except AttributeError:
                pass

        return result
828134
def change_column(column_name, definition)
      attributes = column_attributes(column_name, definition)
      migration.change_column(*attributes)
    end
807122
def save_file(self, filename, encoding='utf8', headers=None,
                  convertors=None, display=True, **kwargs):
        
        global save_file
        
        convertors = convertors or {}
        headers = headers or []
        
        fields = self.get_fields()
        _header = []
        for i, column in enumerate(fields):
            if column.name not in convertors:
                if display:
                    def f(value, data):
                        return column.get_display_value(value)

                    convertors[column.name] = f
            flag = False
            for j in headers:
                if not isinstance(j, dict):
                    raise ValueError("Header should be a list of dict, but {} type found".format(type(j)))
                if j['name'] == column.name:
                    _header.append(j)
                    flag = True
                    break
            if not flag:
                d = {'name':column.name}
                if display:
                    d['title'] = column.verbose_name or column.name
                else:
                    d['title'] = column.name
                _header.append(d)

        return save_file(self.run(), filename, encoding=encoding,
                         headers=_header, convertors=convertors, **kwargs)
932626
def add_data(self, data):  # add append option later
        
        df = pd.DataFrame(data)
        name, dtype = self.get_singular_and_plural_dtype(self.dtype)
        if name in df.columns:
            df.index = df[name]
        df.index.name = name + " name"
        self.df = df
1154940
def _in_header(self, col):
        """"""
        # pylint: disable=R1704
        if not self._has_header:
            # Conditionally register exceptions so that they do not appear
            # in situations where has_header is always True. In this way
            # they are not auto-documented by default
            icol_ex = pexdoc.exh.addex(RuntimeError, "Invalid column specification")
        hnf_ex = pexdoc.exh.addex(ValueError, "Column *[column_identifier]* not found")
        col_list = [col] if isinstance(col, (str, int)) else col
        for col in col_list:
            edata = {"field": "column_identifier", "value": col}
            if not self._has_header:
                # Condition not subsumed in raise_exception_if
                # so that calls that always have has_header=True
                # do not pick up this exception
                icol_ex(not isinstance(col, int))
                hnf_ex((col < 0) or (col > len(self._header) - 1), edata)
            else:
                hnf_ex(
                    (isinstance(col, int) and ((col < 0) or (col > self._data_cols)))
                    or (
                        isinstance(col, str) and (col.upper() not in self._header_upper)
                    ),
                    edata,
                )
        return col_list
1217251
def column(self, col):
        
        if type(col) is str:
            for c in self._cols:
                if c.name == col:
                    return c
        else:
            return self._cols[col]