Created
September 29, 2019 07:31
-
-
Save tutv/945362542863a315ee648c1f156fc01c to your computer and use it in GitHub Desktop.
Simple export to csv
This file contains hidden or 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 {Parser} = require('json2csv') | |
| const data = [ | |
| { | |
| name: 'Max', | |
| url: 'https://github.com/tutv' | |
| }, | |
| { | |
| name: 'Min', | |
| url: 'https://github.com/m' | |
| } | |
| ] | |
| const fields = [{label: 'Name', value: 'name'}, {label: 'Url', value: 'url'}] | |
| const x = new Parser({fields}) | |
| const content = x.parse(data) | |
| console.log(content) | |
| //"Name","Url" | |
| //"Max","https://github.com/tutv" | |
| //"Min","https://github.com/m" | |
| //Write to file if you want to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment