Created
March 13, 2024 03:11
-
-
Save kkhanal18/2dd830256db4b2f25b7b0f4da1b5de46 to your computer and use it in GitHub Desktop.
json to csv
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') | |
const Papa = require('papaparse'); | |
async function main() { | |
const API = "https://www.fda.gov/about-fda/data-export/downloadable-files?_format=json&field_foia_record_type%5b%5d=3949&field_foia_record_type%5b%5d%20=3950" | |
const response = await fetch(API) | |
let data = await response.json(); | |
csv = Papa.unparse(data) | |
fs.writeFile('fasdfasdf.csv',csv, err => { | |
if (err) { | |
console.error('Error writing to CSV file:', err); | |
return; | |
} | |
console.log('CSV file has been saved!'); | |
}); | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment