Published
Edited
Sep 4, 2021
Fork of Compare CSV
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//_.sortBy(_.groupBy(freq), (g) => -g.length)
Insert cell
Insert cell
log = console.log
Insert cell
diffs = (colsa, colsb) => {
const auenrs = _.keys(ag)
const buenrs = _.keys(bg)
const n = Math.min(auenrs.length, buenrs.length)
const result = []
for (const uenr of auenrs) {
const alist = ag[uenr]
const blist = bg[uenr]
if (!alist || !blist) {
result.push([uenr,'Olika antal medlemmar'])
} else if (alist.length != blist.length) {
result.push([uenr,'Olika antal medlemmar', alist.length, blist.length])
} else {
for (const i of _.range(alist.length)) {
const aRow = alist[i]
const bRow = blist[i]

//result.push(aRow.purpose + '-' + bRow.HAR)
//result.push(aRow.mode + '-' + bRow.Fardsatt)
//continue

const purposeTrans = {1:'Arbete',2:'Skola',3:'Tjänste',5:'SHB',6:'SHB',7:'SHB', 8:'Släkt',9:'Rekr',10:'Skjutsa',12:'Daglig', 13:'Sällan', 99:'Rekr'}
if (bRow.HAR in purposeTrans) bRow.HAR = purposeTrans[bRow.HAR]

const modeTrans = {1:'bil', 2:'pass', 3:'koll', 4:'koll',5:'gång',6:'cykel',7:'övrigt'}
if (bRow.Fardsatt in modeTrans) bRow.Fardsatt = modeTrans[bRow.Fardsatt]

for (const iCol of _.range(colsa.length)) {
const aKey = colsa[iCol]
const bKey = colsb[iCol]
if (aRow[aKey] != bRow[bKey]) {
log(aRow[aKey],bRow[bKey])
result.push([uenr, aKey,aRow[aKey],bKey,bRow[bKey]])
}
}
}
}
}
return result
}
// diffs = (colsa, colsb) => {
// const n = Math.min(a.length, b.length)
// const result = []
// for (const i of _.range(n)) {
// const ao = a[i]
// const bo = b[i]
// log(i,ao,bo)
// const items = [(2+i).toString()]
// for (const j of _.range(colsa.length)) {
// const cola = colsa[j]
// const colb = colsb[j]
// if (ao[cola] != bo[colb]) {
// items.push(cola+':'+ao[cola]+'!='+bo[colb])
// }
// }
// if (items.length>1) result.push([ao, bo, items.join(' ')])
// }
// return result
// }
Insert cell
Insert cell
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