Public
Edited
Oct 11, 2023
Insert cell
Insert cell
logs_stream = await FileAttachment("logs.ndjson").stream()
Insert cell
text_stream = logs_stream.pipeThrough(new TextDecoderStream())
Insert cell
reader = text_stream.getReader()
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
{
while (i < 10) {
mutable i++
const { done, value } = await reader.read();
mutable buffer = mutable buffer + value;
mutable splits = buffer.split("\n");
console.log(splits)
if (splits.length > 1) {
mutable logs.push(JSON.parse(splits[0]));
mutable buffer = splits[1];
}
}
}
Insert cell
mutable logs = []
Insert cell
mutable buffer = ""
Insert cell
mutable splits = []
Insert cell
mutable i = 0
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