我有一个像这样的数据结构:
map [ [ 'Polio',
'Difterite',
'Tetano',
'Pertosse',
'Epatite B',
'Hib',
'Morbillo',
'Parotite',
'Rosolia',
'Varicella',
'Meningococco C coniugato',
'Pneumococco coniugato' ],
[ 'Piemonte',
'Valle D\'Aosta',
'Lombardia',
'Prov Auton Bolzano',
'Prov Auton Trento',
'Veneto',
'Friuli Venezia Giulia',
'Liguria',
'Emilia Romagna',
'Toscana',
'Umbria',
'Marche',
'Lazio',
'Abruzzo',
'Molise',
'Campania',
'Puglia',
'Basilicata',
'Calabria',
'Sicilia',
'Sardegna',
'MEDIA NAZIONALE' ],
[ '95,16',
'94,90',
'95,43',
'94,87',
'94,62',
'93,80',
'88,72',
'88,72',
'88,72',
'0,85',
'86,35',
'91,32' ],
[ '93,40',
'92,92',
'93,60',
'92,82',
'92,63',
'92,63',
'82,25',
'82,15',
'82,15',
'0,39',
'83,12',
'88,46' ],
[ '93,48',
'93,37',
'93,63',
'93,38',
'93,20',
'92,95',
'90,32',
'90,21',
'90,24',
'0,83',
'85,77',
'86,77' ],
[ '87,45',
'87,49',
'87,50',
'87,45',
'87,11',
'87,17',
'68,84',
'68,80',
'68,80',
'4,16',
'63,12',
'81,67' ],
[ '92,83',
'92,66',
'93,10',
'92,52',
'92,13',
'91,95',
'84,55',
'84,38',
'84,45',
'3,04',
'83,13',
'87,34' ],
[ '91,27',
'91,29',
'91,75',
'91,26',
'90,80',
'90,62',
'87,15',
'87,05',
'87,08',
'84,03',
'90,54',
'84,64' ],
[ '90,37',
'90,28',
'90,78',
'90,22',
'89,66',
'89,59',
'82,01',
'81,85',
'81,91',
'66,95',
'84,06',
'81,02' ],
[ '94,60',
'94,50',
'94,57',
'94,49',
'94,30',
'93,92',
'81,48',
'81,32',
'81,49',
'10,57',
'79,65',
'92,80' ],
[ '94,03',
'93,75',
'94,28',
'93,63',
'93,49',
'92,93',
'87,23',
'87,00',
'87,00',
'0,90',
'87,40',
'91,53' ],
[ '94,98',
'94,95',
'95,23',
'94,96',
'94,81',
'94,57',
'88,72',
'88,67',
'88,69',
'78,21',
'90,85',
'92,94' ],
[ '93,90',
'93,78',
'93,96',
'93,71',
'93,43',
'93,65',
'87,51',
'87,46',
'87,46',
'0,52',
'85,72',
'90,32' ],
[ '92,02',
'91,75',
'92,13',
'91,74',
'91,65',
'91,52',
'79,90',
'79,87',
'79,87',
'2,75',
'76,86',
'88,04' ],
[ '95,26',
'95,24',
'95,25',
'95,21',
'95,20',
'95,20',
'84,47',
'84,46',
'84,46',
'6,51',
'68,16',
'91,85' ],
[ '95,72',
'95,71',
'95,72',
'95,71',
'95,71',
'95,71',
'84,23',
'84,23',
'84,23',
'4,91',
'65,43',
'86,34' ],
[ '94,32',
'94,32',
'94,32',
'94,32',
'94,32',
'94,32',
'77,38',
'77,38',
'77,38',
'47,68',
'68,09',
'92,63' ],
[ '91,34',
'91,34',
'91,34',
'91,34',
'91,36',
'91,49',
'80,76',
'80,76',
'80,76',
'9,15',
'50,04',
'82,96' ],
[ '93,80',
'93,81',
'93,81',
'93,81',
'93,80',
'93,73',
'84,15',
'84,15',
'84,15',
'81,82',
'77,32',
'92,54' ],
[ '97,83',
'97,83',
'97,83',
'97,83',
'97,83',
'97,83',
'90,25',
'90,25',
'90,25',
'76,95',
'85,83',
'97,08' ],
[ '95,32',
'95,32',
'95,32',
'95,32',
'95,32',
'95,24',
'84,38',
'84,38',
'83,71',
'53,02',
'67,90',
'88,65' ],
[ '91,94',
'91,92',
'91,92',
'91,92',
'91,92',
'91,91',
'79,20',
'79,18',
'79,18',
'75,36',
'60,48',
'89,37' ],
[ '95,05',
'95,05',
'95,07',
'95,05',
'95,06',
'95,05',
'87,67',
'87,67',
'87,67',
'67,15',
'83,59',
'94,14' ],
[ '93,43',
'93,35',
'93,56',
'93,33',
'93,20',
'93,03',
'85,29',
'85,23',
'85,22',
'30,73',
'76,62',
'88,73' ] ]
即一个疾病数组,一个用于区域,一个数组用于每一行table值。
我希望在这样的json对象中转换这些数据:
json [ { year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '93,40' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '93,48' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Autonoma Bolzano',
coverage: '87,45' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Autonoma Trento',
coverage: '92,83' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '91,27' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '90,37' },
...]
事实上,这些数据已经从这个pdf中恢复,因此目的是重建table。
我知道这很简单,只需创建循环并迭代。
这是我的代码:
for(var i = 0; i < map[0].length; i++) {
for(var j = 2; j < map.length; j++) {
for(var k = 0; k < map[2].length; k++) {
var year = 2015;
var country = "Italy";
var vaccine = map[0][i];
var region = map[2][j];
var coverage = map[j][k];
// create this json object
var thisJson = {year: year, country: country, vaccine: vaccine, region: region, coverage: coverage};
// push this element to final json object
json.push(thisJson);
}
}
}
结果是:
json [ { year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Piemonte',
coverage: '95,16' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Valle D\'Aosta',
coverage: '94,90' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Lombardia',
coverage: '95,43' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Bolzano',
coverage: '94,87' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Prov Auton Trento',
coverage: '94,62' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Veneto',
coverage: '93,80' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Friuli Venezia Giulia',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Liguria',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Emilia Romagna',
coverage: '88,72' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
{ year: 2015,
country: 'Italy',
vaccine: 'Polio',
region: 'Toscana',
coverage: '0,85' },
... 2540 more items ]
显然它不起作用。索引一定存在问题我无法解决。
答案 0 :(得分:0)
您可以使用shift
删除第一个元素。并使用reduce
和forEach
进行迭代。
var diseases = data.shift(); /* Remove the first element and store it on variable */
var region = data.shift(); /* Remove the first element and store it on variable */
var year = 2015;
var country = 'Italy';
var result = data.reduce((c, v, i) => {
v.forEach((o, k) => {
c.push({year: year,country: country,vaccine: diseases[k],region: region[i],coverage: o});
});
return c;
}, []);
这是一个片段
var data = [
['Polio',
'Difterite',
'Tetano',
'Pertosse',
'Epatite B',
'Hib',
'Morbillo',
'Parotite',
'Rosolia',
'Varicella',
'Meningococco C coniugato',
'Pneumococco coniugato'
],
['Piemonte',
'Valle D\'Aosta',
'Lombardia',
'Prov Auton Bolzano',
'Prov Auton Trento',
'Veneto',
'Friuli Venezia Giulia',
'Liguria',
'Emilia Romagna',
'Toscana',
'Umbria',
'Marche',
'Lazio',
'Abruzzo',
'Molise',
'Campania',
'Puglia',
'Basilicata',
'Calabria',
'Sicilia',
'Sardegna',
'MEDIA NAZIONALE'
],
['95,16',
'94,90',
'95,43',
'94,87',
'94,62',
'93,80',
'88,72',
'88,72',
'88,72',
'0,85',
'86,35',
'91,32'
],
['93,40',
'92,92',
'93,60',
'92,82',
'92,63',
'92,63',
'82,25',
'82,15',
'82,15',
'0,39',
'83,12',
'88,46'
],
['93,48',
'93,37',
'93,63',
'93,38',
'93,20',
'92,95',
'90,32',
'90,21',
'90,24',
'0,83',
'85,77',
'86,77'
],
['87,45',
'87,49',
'87,50',
'87,45',
'87,11',
'87,17',
'68,84',
'68,80',
'68,80',
'4,16',
'63,12',
'81,67'
],
['92,83',
'92,66',
'93,10',
'92,52',
'92,13',
'91,95',
'84,55',
'84,38',
'84,45',
'3,04',
'83,13',
'87,34'
],
['91,27',
'91,29',
'91,75',
'91,26',
'90,80',
'90,62',
'87,15',
'87,05',
'87,08',
'84,03',
'90,54',
'84,64'
],
['90,37',
'90,28',
'90,78',
'90,22',
'89,66',
'89,59',
'82,01',
'81,85',
'81,91',
'66,95',
'84,06',
'81,02'
],
['94,60',
'94,50',
'94,57',
'94,49',
'94,30',
'93,92',
'81,48',
'81,32',
'81,49',
'10,57',
'79,65',
'92,80'
],
['94,03',
'93,75',
'94,28',
'93,63',
'93,49',
'92,93',
'87,23',
'87,00',
'87,00',
'0,90',
'87,40',
'91,53'
],
['94,98',
'94,95',
'95,23',
'94,96',
'94,81',
'94,57',
'88,72',
'88,67',
'88,69',
'78,21',
'90,85',
'92,94'
],
['93,90',
'93,78',
'93,96',
'93,71',
'93,43',
'93,65',
'87,51',
'87,46',
'87,46',
'0,52',
'85,72',
'90,32'
],
['92,02',
'91,75',
'92,13',
'91,74',
'91,65',
'91,52',
'79,90',
'79,87',
'79,87',
'2,75',
'76,86',
'88,04'
],
['95,26',
'95,24',
'95,25',
'95,21',
'95,20',
'95,20',
'84,47',
'84,46',
'84,46',
'6,51',
'68,16',
'91,85'
],
['95,72',
'95,71',
'95,72',
'95,71',
'95,71',
'95,71',
'84,23',
'84,23',
'84,23',
'4,91',
'65,43',
'86,34'
],
['94,32',
'94,32',
'94,32',
'94,32',
'94,32',
'94,32',
'77,38',
'77,38',
'77,38',
'47,68',
'68,09',
'92,63'
],
['91,34',
'91,34',
'91,34',
'91,34',
'91,36',
'91,49',
'80,76',
'80,76',
'80,76',
'9,15',
'50,04',
'82,96'
],
['93,80',
'93,81',
'93,81',
'93,81',
'93,80',
'93,73',
'84,15',
'84,15',
'84,15',
'81,82',
'77,32',
'92,54'
],
['97,83',
'97,83',
'97,83',
'97,83',
'97,83',
'97,83',
'90,25',
'90,25',
'90,25',
'76,95',
'85,83',
'97,08'
],
['95,32',
'95,32',
'95,32',
'95,32',
'95,32',
'95,24',
'84,38',
'84,38',
'83,71',
'53,02',
'67,90',
'88,65'
],
['91,94',
'91,92',
'91,92',
'91,92',
'91,92',
'91,91',
'79,20',
'79,18',
'79,18',
'75,36',
'60,48',
'89,37'
],
['95,05',
'95,05',
'95,07',
'95,05',
'95,06',
'95,05',
'87,67',
'87,67',
'87,67',
'67,15',
'83,59',
'94,14'
],
['93,43',
'93,35',
'93,56',
'93,33',
'93,20',
'93,03',
'85,29',
'85,23',
'85,22',
'30,73',
'76,62',
'88,73'
]
];
var diseases = data.shift(); /* Remove the first element */
var region = data.shift(); /* Remove the first element */
var year = 2015;
var country = 'Italy';
var result = data.reduce((c, v, i) => {
v.forEach((o, k) => {
c.push({year: year,country: country,vaccine: diseases[k],region: region[i],coverage: o});
});
return c;
}, []);
console.log(result);