This commit is contained in:
Aleksandr Statciuk 2022-01-23 04:39:25 +03:00
commit 8132a25d1b
11 changed files with 33970 additions and 0 deletions

23
update.js Normal file
View file

@ -0,0 +1,23 @@
const csv = require('csvtojson')
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const DATABASE_DIR = './database'
const OUTPUT_DIR = './.gh-pages'
fs.exists(OUTPUT_DIR, function (exists) {
if (!exists) {
fs.mkdirSync(OUTPUT_DIR)
}
})
glob(`${DATABASE_DIR}/*.csv`, async function (err, files) {
for (const inputFile of files) {
const inputFilename = path.parse(inputFile).name
const outputFile = `${OUTPUT_DIR}/${inputFilename}.json`
const json = await csv().fromFile(inputFile)
fs.writeFileSync(path.resolve(outputFile), JSON.stringify(json))
}
})