Public
Edited
Mar 2, 2023
Insert cell
Insert cell
default_data_types = { return { "Created Date": "date", "Modified Date": "date", "Created By": "text", "Slug": "text" } }
Insert cell
function normalize_data_type_name(x) {
// replace non alphanumerics (except for whitespace) with underscores then trim leading and trailing whitespace
return x.replaceAll(/[^0-9a-zA-Z ]/g, '_').replace(/^\s+|\s+$/gm, '')
}

Insert cell
function sort_dictionary_by_keys(_dict) {
return Object.keys(_dict).sort().reduce(
(obj, key) => {
obj[key] = _dict[key];
return obj;
},
{}
);
}
Insert cell
user_types = { return }
Insert cell
{
let data_type_dict_consumer = {}
for (const [k, v] of Object.entries(user_types)) {
if (Object.keys(v).includes('%f3')) {
var temp_object = {}
for (const [k_inner, v_inner] of Object.entries(v['%f3'])) {
if (!Object.keys(v_inner).includes('%del')) {
temp_object[v_inner['%d']] = v_inner['%v']
}
}
data_type_dict_consumer[normalize_data_type_name(v['%d'])] = sort_dictionary_by_keys({ ...temp_object, ...default_data_types })
}
}
return data_type_dict_consumer
}
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