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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more