Public
Edited
May 18
2 forks
Insert cell
Insert cell
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data = FileAttachment("ships.json").json({typed: true})
Insert cell
Insert cell
// this code returns a new copy of the object
data.map(ship=>{
let DisplacementStandard, DisplacementFull;
// check if the cell is undefined
if (ship.Displacement){
// parseFloat convert string to a floating point number
// characters are automatically ignored
DisplacementStandard = parseFloat(ship.Displacement.split(";")[0]);
if (ship.Displacement.split(";")[1]){
DisplacementFull = parseFloat(ship.Displacement.split(";")[1]);
}
}
// create a copy of the ship object
return {
...ship,
DisplacementStandard: DisplacementStandard,
DisplacementFull: DisplacementFull,
};
})
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