Published
Edited
Dec 4, 2021
Insert cell
Insert cell
raw = FileAttachment("test.txt").text()
Insert cell
inputFile = Array.from(raw.split('\n'))
Insert cell
draws = inputFile[0].split(',')
Insert cell
inputFile.slice(1).filter(s => s !== '')
Insert cell
boards1d = {
let tmp = inputFile.slice(1).filter(s => s !== '')
let out = []
for (let row = 0; row < tmp.length; row++) {
if (row % 5 === 0) {
out.push(tmp.slice(row, row + 5))
}
}
return out
}
Insert cell
boards1d
.map(arr => arr.map(s => s.trim()))
.map(arr => arr.map(s => s.replace(' ', ' '))) // 2 space -> 1 space
Insert cell
boards1d[0].map(x => x.trim().replace(' ', ' '))
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