Published
Edited
Feb 7, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
all_records = {
let all_records = [];
let all_headers = '\n';
for (var sheetName in doubtufulData) {
let to_skip = sheetName.includes('SKIP');
if (!to_skip){
let sheet = doubtufulData[sheetName];
all_records = all_records.concat(sheet.elements);
all_headers += sheet.columnNames + '\n';
}
}
all_records = all_records.map(d=>{
return {
...d,
'year': corpusData.publications.filter(p=>p.id===d['ID opera'])[0].year,
'length': corpusData.titles.filter(p=>p.id===d['ID opera'])[0].txt_length
}
})
console.log('all_records', all_records)
mutable data = all_records;
return all_records;
}
Insert cell
Insert cell
with_years = {
console.log(all_records)
let all_records_plus_years = all_records.map(d=>{
console.log(corpusData.publications.filter(p=>p.id===d['ID opera'])[0].year)
return {
...d,
'year': corpusData.publications.filter(p=>p.id===d['ID opera'])[0].year
}
})
mutable data = all_records_plus_years;
return all_records_plus_years;
}
Insert cell
Insert cell
with_dates = {
let with_dates = with_years.map(d=>{
let year = corpusData.publications.filter(p=>p.id===d['ID opera'])[0].year
let month = corpusData.publications.filter(p=>p.id===d['ID opera'])[0].month
let day = corpusData.publications.filter(p=>p.id===d['ID opera'])[0].day
let this_date_complete = `${year}-${month}-${day}`
return {
...d,
'date_complete': this_date_complete
}
})
mutable data = with_dates;
return with_dates;
}
Insert cell
Insert cell
with_size = {
let with_size = with_dates.map(r=>{
return {
...r,
'size': r.ends_at - r.starts_at
}
})
mutable data = with_size;
return with_size;
}
Insert cell
Insert cell
with_categories = {
let with_cats = with_size.map(d=>{
return {
...d,
'category': d.macro_categoria===""?"alternativa":"dubbio"
}
});
mutable data = with_cats;
return with_cats;
}
Insert cell
with_lengths = {
let with_lengths = with_categories.map(d=>{
return {
...d,
'length': corpusData.titles.filter(p=>p.id===d['ID opera'])[0].txt_length,
'title': corpusData.titles.filter(p=>p.id===d['ID opera'])[0].title,
'year': corpusData.publications.filter(p=>p.id===d['ID opera'])[0].year
}
});
mutable data = with_lengths;
return with_lengths;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable subject_how_many_times = []
Insert cell
mutable data_bars_matrix_exp = []
Insert cell
data_bars_matrix_exp.find(d=>d.source==='V021')
Insert cell
{
let data_phase_2 = mutable data_bars_matrix_exp.slice(0);
let data_how_many_times = mutable subject_how_many_times;
console.log("data_how_many_times", data_how_many_times);
data_phase_2.forEach(d=>{
if (!d.id) {
d["id"] = d["source"];+
delete d["source"];
}
if (!d.year) {
d["year"] = d["year_title"].split(" - ")[0].replace(",","");
delete d["year_title"];
}
if (d.dubbio == d.misto == d.soggetto == d.definitivo) {
d.definitivo = d.length;
d.definitivo_perc = 100;
}
d.details = with_lengths
.filter(dd=>dd["ID opera"]===d.id)
.filter(dd=>dd["Testo Alternativo"]!=="YES");
if (data_how_many_times.find(dd=>dd.id===d.id)) {
d.levels_doubt = data_how_many_times.find(dd=>dd.id===d.id).data
d.levels_doubt = d.levels_doubt.map(l=>{
console.log("level", l)
l.name = l.key;
l.children = l.values.map(c=>{
return {
'name': c.key,
'value': c.value
}
});
delete l.key;
delete l.values;
return l;
})
console.log(d.levels_doubt)
} else {
d.levels_doubt = []
}
})
return data_phase_2;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more