add custom data to data store
428157
def record(self, timestamp, *args, **kwargs):
        
        if self.output_file is None:
            return

        data = {'datetime': timestamp}

        # append all data
        if len(args) == 1:
            if isinstance(args[0], dict):
                data.update(dict(args[0]))
            elif isinstance(args[0], pd.DataFrame):
                data.update(args[0][-1:].to_dict(orient='records')[0])

        # add kwargs
        if kwargs:
            data.update(dict(kwargs))

        data['datetime'] = timestamp
        # self.rows.append(pd.DataFrame(data=data, index=[timestamp]))

        new_data = {}
        if "symbol" not in data.keys():
            new_data = dict(data)
        else:
            sym = data["symbol"]
            new_data["symbol"] = data["symbol"]
            for key in data.keys():
                if key not in ['datetime', 'symbol_group', 'asset_class']:
                    new_data[sym + '_' + str(key).upper()] = data[key]

        new_data['datetime'] = timestamp

        # append to rows
        self.rows.append(pd.DataFrame(data=new_data, index=[timestamp]))

        # create dataframe
        recorded = pd.concat(self.rows, sort=True)

        if "symbol" not in recorded.columns:
            return


        # group by symbol
        recorded['datetime'] = recorded.index
        data = recorded.groupby(['symbol', 'datetime'], as_index=False).sum()
        data.set_index('datetime', inplace=True)

        symbols = data['symbol'].unique().tolist()
        data.drop(columns=['symbol'], inplace=True)


        # cleanup:

        # remove symbols
        recorded.drop(['symbol'] + [sym + '_SYMBOL' for sym in symbols],
                      axis=1, inplace=True)

        # remove non-option data if not working with options
        for sym in symbols:
            try:
                opt_cols = recorded.columns[
                    recorded.columns.str.startswith(sym + '_OPT_')].tolist()
                if len(opt_cols) == len(recorded[opt_cols].isnull().all()):
                    recorded.drop(opt_cols, axis=1, inplace=True)
            except Exception as e:
                pass

        # group df
        recorded = recorded.groupby(recorded['datetime']).first()

        # shift position
        for sym in symbols:
            recorded[sym + '_POSITION'] = recorded[sym + '_POSITION'
                                                   ].shift(1).fillna(0)

        # make this public
        self.recorded = recorded.copy()

        # cleanup columns names before saving...
        recorded.columns = [col.replace('_FUT_', '_').replace(
                            '_OPT_OPT_', '_OPT_') for col in recorded.columns]

        # save
        if ".csv" in self.output_file:
            recorded.to_csv(self.output_file)
        elif ".h5" in self.output_file:
            recorded.to_hdf(self.output_file, 0)
        elif (".pickle" in self.output_file) | (".pkl" in self.output_file):
            recorded.to_pickle(self.output_file)

        chmod(self.output_file)
1199373
def import_data(self, data_items):
        
        # keep counts of all actions
        record = {
            'insert': 0, 'update': 0, 'noop': 0,
            'start': utcnow(),
            'records': {
                'insert': [],
                'update': [],
                'noop': [],
            }
        }

        for json_id, data in self._prepare_imports(data_items):
            obj_id, what = self.import_item(data)
            self.json_to_db_id[json_id] = obj_id
            record['records'][what].append(obj_id)
            record[what] += 1

        # all objects are loaded, a perfect time to do inter-object resolution and other tasks
        self.postimport()

        record['end'] = utcnow()

        return {self._type: record}
1321921
function store(options) {
  options = options || {};
  var DataStore = lazy.DataStore();
  var opts = extend(options.store || {});
  return new DataStore('snippets', opts);
}
695901
final void addData(final AbstractMeter meter, final double data) {
        checkIfMeterExists(meter);
        meterResults.get(meter).add(data);
    }
1087107
def addValue(self, source, data):
    """"""
    self.__result[self._dataFormat.getValue(data)].append(source)
180144
function Data(options) {
  if (!(this instanceof Data)) {
    return new Data(options);
  }
  var opts = utils.merge({cwd: path.resolve(__dirname, '../../.data')}, options);
  Base.call(this, null, opts);
  this.define('store', utils.store('npm-api', this.options));
}
925966
def set_custom_data(name, value)
      unless @custom_data_labels.include?(name)
        PEROBS.log.fatal "Unknown custom data field #{name}"
      end

      @custom_data_values[@custom_data_labels.index(name)] = value
      write_header if @f
    end
800108
function add(data, unfilteredOptions) {
        let options = this.filterOptions(unfilteredOptions, 'add', {extraAllowedProperties: ['id']});

        const addPost = (() => {
            return ghostBookshelf.Model.add.call(this, data, options)
                .then((post) => {
                    return this.findOne({
                        status: 'all',
                        id: post.id
                    }, _.merge({transacting: options.transacting}, unfilteredOptions));
                });
        });

        if (!options.transacting) {
            return ghostBookshelf.transaction((transacting) => {
                options.transacting = transacting;

                return addPost();
            });
        }

        return addPost();
    }
1271296
private function createData() : void
    {
        $this->data = [
            'foo' => 'some foo string',
            'bar' => 42,
            'baz' => new DateTime(),
            'someFooProperty' => [12, 13, 14],
            'someBarProperty' => 12354.4578,
            'someBazProperty' => new stdClass(),
            'foo1' => 'some foo string',
            'bar1' => 42,
            'baz1' => new DateTime(),
            'someFooProperty1' => [12, 13, 14],
            'someBarProperty1' => 12354.4578,
            'someBazProperty1' => new stdClass(),
            'foo2' => 'some foo string',
            'bar2' => 42,
            'baz2' => new DateTime(),
            'someFooProperty2' => [12, 13, 14],
            'someBarProperty2' => 12354.4578,
            'someBazProperty2' => new stdClass(),
        ];
    }
563124
def get_data_store(args):
    """"""
    return tacl.DataStore(args.db, args.memory, args.ram)
133981
def add_new_fields(data, data_to_add):
        
        for key, value in data_to_add.items():
            if not data.get(key):
                data[key] = value

        return data
78186
def add_data(self, request, pk=None):
        """"""
        # add data to entity
        resp = super().add_data(request, pk)

        # add data to collections in which entity is
        entity = self.get_object()
        for collection in entity.collections.all():
            collection.data.add(*request.data['ids'])

        return resp
766203
def AddEventData(self, event_data):
    
    self._RaiseIfNotWritable()

    self._AddAttributeContainer(self._CONTAINER_TYPE_EVENT_DATA, event_data)
664839
def existingInStore(cls, store, storeID, attrs):
        """"""
        self = cls.__new__(cls)

        self.__justCreated = False
        self.__subinit__(__store=store,
                         storeID=storeID,
                         __everInserted=True)

        schema = self.getSchema()
        assert len(schema) == len(attrs), "invalid number of attributes"
        for data, (name, attr) in zip(attrs, schema):
            attr.loaded(self, data)
        self.activate()
        return self
885000
public void addDatabaseProperty(String strKey, String strValue)
    {
        this.setProperty(strKey, strValue);
        Environment env = (Environment)this.getDatabaseOwner().getEnvironment();
        if (env.getCachedDatabaseProperties(this.getDatabaseName(true)) != null)  // Always
            if (env.getCachedDatabaseProperties(this.getDatabaseName(true)) != Environment.DATABASE_DOESNT_EXIST)  // Always
                env.getCachedDatabaseProperties(this.getDatabaseName(true)).put(strKey, strValue);
    }
1290125
function addData( $attributes ) {
		if( !isset( $this->data ) ) {
			$this->data = new dbData( $this, $attributes );
		}
		return $this->data;
	}
209868
def add_data(self, *args):
        """"""
        for data in args:
            self._data.append(to_binary(data))