Skip to content

Instantly share code, notes, and snippets.

@neysidev
Created April 17, 2022 10:34
Show Gist options
  • Select an option

  • Save neysidev/8a240f23680086b2420d0e07fcb63a31 to your computer and use it in GitHub Desktop.

Select an option

Save neysidev/8a240f23680086b2420d0e07fcb63a31 to your computer and use it in GitHub Desktop.
const fs = require("fs")
fs.readFile("input.csv", "utf8", (err, data) => {
if (err) return console.log(err)
const content = []
data.split("\n").forEach(line => {
content.push(line.split(","))
})
fs.writeFile("output.json", JSON.stringify(content), err => {
if (err) return console.log(err)
console.log("The file was saved!")
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment