iptv-database/scripts/db/export.js

16 lines
464 B
JavaScript
Raw Normal View History

2022-02-11 22:29:23 -05:00
const { csv, file } = require('../core')
2022-02-11 21:55:50 -05:00
const DATA_DIR = process.env.DATA_DIR || './data'
const OUTPUT_DIR = process.env.OUTPUT_DIR || './.gh-pages'
2022-02-11 22:29:23 -05:00
async function main() {
const files = await file.list(`${DATA_DIR}/*.csv`)
2022-02-11 21:55:50 -05:00
for (const inputFile of files) {
2022-02-11 22:29:23 -05:00
const inputFilename = file.getFilename(inputFile)
2022-02-11 21:55:50 -05:00
const json = await csv.load(inputFile)
2022-02-11 22:29:23 -05:00
await file.create(`${OUTPUT_DIR}/${inputFilename}.json`, JSON.stringify(json))
2022-02-11 21:55:50 -05:00
}
2022-02-11 22:29:23 -05:00
}
main()