38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// merge_ksa.js
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import parseLine from './parseLine.js'; // your parseLine from above
|
|
|
|
function parseTextFile(filepath, ksaType) {
|
|
const raw = fs.readFileSync(filepath, 'utf8');
|
|
const lines = raw.split('\n').map(line => line.trim()).filter(Boolean);
|
|
|
|
// convert each line to an object with 15 columns
|
|
// then attach ksa_type
|
|
return lines.map((line) => {
|
|
const parsed = parseLine(line);
|
|
return {
|
|
...parsed,
|
|
ksa_type: ksaType
|
|
};
|
|
});
|
|
}
|
|
|
|
function main() {
|
|
// Adjust to your real file paths
|
|
const knowledgeFile = path.resolve('Knowledge.txt');
|
|
const skillsFile = path.resolve('Skills.txt');
|
|
const abilitiesFile = path.resolve('Abilities.txt');
|
|
|
|
const knowledgeData = parseTextFile(knowledgeFile, 'Knowledge');
|
|
const skillsData = parseTextFile(skillsFile, 'Skill');
|
|
const abilitiesData = parseTextFile(abilitiesFile, 'Ability');
|
|
|
|
const merged = [...knowledgeData, ...skillsData, ...abilitiesData];
|
|
|
|
fs.writeFileSync('ksa_data.json', JSON.stringify(merged, null, 2), 'utf8');
|
|
console.log(`Wrote ${merged.length} lines (incl. headers) to ksa_data.json`);
|
|
}
|
|
|
|
main();
|