mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-13 02:53:45 +00:00
feat(*): Add tsv parser to enable easily loading pokedex data
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const fs = require('fs');
|
||||
const csv = require('csv-parser');
|
||||
|
||||
const inputFilePath = 'seed-data.tsv'; // Replace with the path to your TSV file
|
||||
const outputFilePath = 'pokedex.json';
|
||||
|
||||
const results = [];
|
||||
|
||||
fs.createReadStream(inputFilePath)
|
||||
.pipe(csv({ separator: '\t' }))
|
||||
.on('data', (data) => {
|
||||
const entry = {
|
||||
pokedexNumber: parseInt(data['Dex #']),
|
||||
boxPlacement: {
|
||||
box: parseInt(data['Home Box']),
|
||||
row: parseInt(data['Home Row']),
|
||||
column: parseInt(data['Home Column'])
|
||||
},
|
||||
pokemon: data['Pokemon'],
|
||||
form: data['Form'],
|
||||
canGigantamax: data['Can Gigantamax'].toLowerCase(),
|
||||
regionToCatchIn: data['Region'],
|
||||
gamesToCatchIn: data['Catch In These Games'].split(',').map((game) => game.trim()),
|
||||
regionToEvolveIn: data['Evolve In Region'],
|
||||
notes: data['Notes to obtain']
|
||||
};
|
||||
results.push(entry);
|
||||
})
|
||||
.on('end', () => {
|
||||
fs.writeFile(outputFilePath, JSON.stringify(results, null, 2), (err) => {
|
||||
if (err) {
|
||||
console.error('Error writing to JSON file', err);
|
||||
} else {
|
||||
console.log('JSON file has been successfully created');
|
||||
}
|
||||
});
|
||||
});
|
||||
Generated
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "tsv-parser",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "tsv-parser",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"csv-parser": "^3.0.0",
|
||||
"fs": "^0.0.1-security"
|
||||
}
|
||||
},
|
||||
"node_modules/csv-parser": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz",
|
||||
"integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"bin": {
|
||||
"csv-parser": "bin/csv-parser"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/fs": {
|
||||
"version": "0.0.1-security",
|
||||
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/minimist": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "tsv-parser",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"csv-parser": "^3.0.0",
|
||||
"fs": "^0.0.1-security"
|
||||
}
|
||||
}
|
||||
+27151
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user