Created
February 13, 2023 10:33
-
-
Save farishan/6ac3cc654a9b58af71ac49de64e9f18a to your computer and use it in GitHub Desktop.
A script to convert https://gist.github.com/farishan/4cdbc082ff19136522bdc5be1a28d754 to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
/* Configuration */ | |
const INPUT_PATH = './disciplines.txt' | |
const OUTPUT_PATH = './disciplines.json' | |
const ENCODING = 'utf-8' | |
const MINIFIED = false | |
const SPACE = 2 | |
const REPLACER = undefined | |
fs.readFile(INPUT_PATH, ENCODING, (err, data) => { | |
if (err) { | |
console.log(err) | |
console.log('error.') | |
} else { | |
console.log(data.split(',')) | |
const json = MINIFIED ? | |
JSON.stringify(data.split(',')) | |
: JSON.stringify(data.split(','), REPLACER, SPACE) | |
fs.writeFile(OUTPUT_PATH, json, function (err) { | |
if (err) { | |
console.log(err) | |
console.log('error.') | |
} | |
}) | |
console.log('done.') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment