const csv = require('fast-csv') const fs = require('fs') let records = [] /** * Parse CSV file and call processor functions on every line. */ function start (dataFile) { csv .parseFile(dataFile, { delimiter: ';' }) .on("data", function (data) { if (data[0] !== 'Bereich') processInput(...data) }) .on("end", createHTML) } /** * Generate one object for every line in the CSV file and push * it to the records array. */ function processInput (section, chair, category, audience, abbreviation, topic, description, deadline, link) { records.push({ section, chair, category, audience, abbreviation, topic, description, deadline, link }) } /** * Generate HTML from the records array. * The resulting markup is written to ./result.txt. */ function createHTML() { let resultString = '' const recordsBySection = groupBy(records, x => x.section) Array.from(['Informatik', 'Angewandte Informatik', 'Wirtschaftsinformatik']) .forEach(function (section) { if (recordsBySection.has(section)) { resultString += `
Kurzbeschreibung: ${cur.description}
\n` resultString += `Anmeldefrist: ${cur.deadline}
\n` resultString += `Weitere Informationen und Anmeldung: `
resultString += cur.link.startsWith('http') ? `
${cur.link}` : cur.link
resultString += `