Public
Edited
Apr 4, 2023
Insert cell
Insert cell
data = {
// cleanup CSV file
// remove first 4 lines
const text = await FileAttachment("API_NY.GDP.MKTP.KD.ZG_DS2_en_csv_v2_5358346.csv").text()
const split = text.split("\n")
const join = split.slice(4).join("\n")
// convert back to csv
return d3.csvParse(join)
}
Insert cell
nld = {
const NLD = data[176]
// delete object properties
delete NLD["Country Name"]
delete NLD["Country Code"]
delete NLD["Indicator Name"]
delete NLD["Indicator Code"]
delete NLD["1960"] // remove null value
delete NLD[""] // remove empty key
return NLD
}
Insert cell
// prepare data for an ApexChart area chart
// convert single object to an array of objects
// with "x" and "y" properties
// x: string | number | Date
// y: number
nld_gdp = {
let gdp = []
for (const key in nld) {
gdp.push({"x": key, "y": nld[key]})
}

return gdp
}
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