formatted = data
.map(function (d) {
const newObj = {};
for (const key in d) {
let newKey = key;
if (
!(
key == "Institution Name" ||
key == "UnitID" ||
key.startsWith("FIPS")
) &&
key
) {
const strings = key.trim().split(" ");
console.log(strings);
const year = +strings[1].slice(2, 6);
const majornum = +strings[3].slice(9, 10);
const cipcode = +strings[7].slice(8, -1);
const awlevel = +strings[5].slice(8);
newKey = `Total_${year}_M${majornum}_CIP${cipcode}_AL${awlevel}`;
}
newObj[newKey] = d[key];
}
return newObj;
})