Public
Edited
Oct 2, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
utils = {
function escapeCSV(str){
if (!str) return str
// google sheets will hide leading single quote when publishing
// a workaround is to double it
let google_fix = ''
if(str.startsWith("'")) {
google_fix = "'"
}
return '"'+ google_fix + str.replaceAll(/\r?\n/g, '\\n').replaceAll(/(?<!\\)"/g, '\\"')+'"'
}
function unescapeCSV(str){
if(!str) return str
// google sheets will hide leading single quote when publishing
// in case it's not from google sheets, deduct it
if(str.startsWith("''")) {
str = str.replace("''", "'")
}
return str.replaceAll(/\\n/g, '\n')
}
function combineID(parentID, childID){
return (parentID ? parentID+'.' : '') + childID
}
return {
escapeCSV,
unescapeCSV,
combineID,
}
}
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