Public
Edited
Oct 2, 2024
Importers
Insert cell
Insert cell
viewof serverType = Inputs.radio(new Map([['国服', 'zh'], ['国际服(en)', 'en']]), {label: '运营地区', value: 'zh'})
Insert cell
enpcNameMap = {
const map = new Map()
for (let idx = 0; idx < enpcResidentCSV.length; ++idx) {
const id = enpcResidentCSV[idx][0]
const name = enpcResidentCSV[idx][1]
if (name) {
map.set(id, name)
}
}
return map
}
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
enpcResidentCSV = {
const en = 'https://raw.githubusercontent.com/xivapi/ffxiv-datamining/master/csv/ENpcResident.csv'
const zh = 'https://raw.githubusercontent.com/thewakingsands/ffxiv-datamining-cn/master/ENpcResident.csv'
const target = serverType === 'zh' ? zh : en
return parseCSV(await (await fetch(target)).text())
}
Insert cell
enpcCSV = {
const en = 'https://raw.githubusercontent.com/xivapi/ffxiv-datamining/master/csv/ENpcBase.csv'
const zh = 'https://raw.githubusercontent.com/thewakingsands/ffxiv-datamining-cn/master/ENpcBase.csv'
const target = serverType === 'zh' ? zh : en
return parseCSV(await (await fetch(target)).text())
}
Insert cell
function parseCSV(text, startsWithZero = false) {
const lineend0 = text.indexOf('\n') // key,0,1 ...
const lineend1 = text.indexOf('\n', lineend0 + 1) // #, Name, ...
const lineend2 = text.indexOf('\n', lineend1 + 1) // int,str, ...
let last = lineend2
if (startsWithZero) {
const lineend3 = text.indexOf('\n', lineend2 + 1) // 0, '', ... , some files don't start with 0
last = lineend3
}
const idxes = text.slice(0, lineend0).split(',')
const labels = text.slice(lineend0 + 1, lineend1).split(',')
return d3.csvParseRows(text.slice(last + 1))
}
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