Published
Edited
Insert cell
Insert cell
viewof experimentId = Inputs.text({
type: "string",
label: html`Type here the <b>experimentId</b>`,
})
Insert cell
data = {
const response = await fetch(`https://youtube.tracking.exposed/api/v2/experiment/${experimentId}/csv/adv`);
const text = await response.text();
return d3.csvParse(text);
}
Insert cell
Insert cell
clean = _.map(data, function(o) {
o.when = new Date(o.clientTime);
return _.omit(o, ['uxLang','savingTime', 'pseudo', 'experimentId', 'login' ]);
});
Insert cell
reduced = _.reduce(clean, function(memo, o) {
if(o.selectorName === memo.lastSelector) /* skip the duplicates */
return memo;
/* else, if is a new one */
memo.lastSelector = o.selectorName;
/* copy the selectorName so if is duplicated we keep only the first */
memo.datum.push(o);
return memo;
}, { datum: [], lastSelector: null } );
Insert cell
_.countBy(reduced.datum, 'selectorName');
Insert cell
_.countBy(clean, 'selectorName');
Insert cell
### content cleaned and reduced, below you'll have a searchable table
Insert cell
Insert cell
Inputs.table(search);
Insert cell
import {serialize} from "@palewire/saving-csv"
Insert cell
DOM.download(serialize(reduced.datum), `cleaned-${experimentId}-ads.csv`, "Download (the cleaned and reduced) CSV")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more