Start a new topic

best method for selecting columns in a duffle?

have a duffle, want to send certain columns to an HTML table component. Best method?

1 person likes this idea

Hey Tom, 

One solution is to use the Simple Entity Filter component (which filters attributes from an entity) inside of a DataDriver component to iterate through the duffle. The DataDriver currently appends the the new data to the old data, so you'd need to filter that back out before passing it along. 

Here I've done that. The DataDriver output selector should be set to "residue" as well as "appendAs". I then use a merge gate to strip out all but the residue. 

This is confusing and performance is poor. It takes it 3-4s to give me a response over just a tiny bit of data and I still don't actually have anything populating residue in the output. 

{ "indicator": "i_obese", "year": 2005, "geoType": "geoTypeState", "geo": "NH", "sex": "Female", "ageType": "ageTypeAllAges", "age": "All ages", "prev": 0.2577, "prev_low": 0.2365, "prev_upp": 0.2802, "pop": 117957.8614, "pop_low": 106391.934, "pop_upp": 129523.7888, "method": "Old Method", "qual": "i_obese Old Method geoTypeState NH Female ageTypeAllAges All ages", "ttqual": "NH; Female; All ages; Old Method", "residue": { }

 I can look into why that's not working, but yes that is a bit slow. 

Here is some code from a merge gate with x0 renamed to data and x1 renamed to filterAttributes. Given a duffle in the data port and a list of attributes in the filterAttributes this will do what you need (and it will be fast).{
	var newEntity = {};
	for(var i = 0; i<filterAttributes.length; i++){
		var attribute = filterAttributes[i];
		newEntity[attribute] = obj[attribute]
	return newEntity;


This works great. Thank you. 

simple select table component now allows for this to occur in the table component itself as well as renaming. 

Login to post a comment