Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Created Mar 23, 2020
Embed
What would you like to do?
const csv = require('csv-parser');
const fs = require('fs');
const endPoints = {}
console.log("digraph g{")
console.log("rankdir=LR;")
console.log("node [style=filled];")
fs.createReadStream('data.csv')
.pipe(csv())
.on('data', (row) => {
endPoints[row.Endpoint] = {}
const depts = row['Internal Dependencies'].split('\n').filter(Boolean)
const testDepts = row['Integration Test Dependencies'].split('\n').filter(Boolean)
const tableDepts = row['Major Internal Table Dependencies'] ?
row['Major Internal Table Dependencies'].split('\n').filter(Boolean) :
[]
const tables = []
depts.forEach((dept) => {
console.log(`"${row.Endpoint}"->"${dept}" [color="0.002 0.999 0.999"]`);
})
tableDepts.forEach((table) => {
console.log(`"${row.Endpoint}"->"${table}"`);
tables.push(table)
})
testDepts.forEach((dept) => {
console.log(`"${row.Endpoint}"->"${row.Endpoint} Integration Test"->"${dept}" [color="0.348 0.839 0.839"]`);
// console.log(`"${row.Endpoint}"->"Integration Test"->"${dept}"`);
})
tables.forEach((table) => {
console.log(`${table} [color="0.650 0.200 1.000"]`);
})
//
})
.on('end', () => {
console.log("}")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment