createGDPArray = function(dataLine, dataString) {
const lines = dataString.trim().split('\n').filter(line => line.trim());
const headers = lines[0].split(',');
const years = headers.slice(2);
const row = dataLine.split(',');
const countryName = row[0];
const countryCode = row[1];
const gdpValues = row.slice(2);
const result = [];
for (let i = 0; i < years.length; i++) {
const year = years[i];
const gdpValue = gdpValues[i];
const parsedYear = parseInt(year);
if (isNaN(parsedYear) || !year || year.trim() === '') {
continue;
}
let parsedGDP = null;
if (gdpValue && gdpValue.trim() !== '') {
const numValue = parseFloat(gdpValue);
if (!isNaN(numValue)) {
parsedGDP = numValue;
}
}
result.push({
"Date": parsedYear,
"GDP": parsedGDP
});
}
return result;
}