Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert only required properties of JSON Array to csv #42

Open
MalateshPatil opened this issue Jan 9, 2018 · 3 comments
Open

Comments

@MalateshPatil
Copy link

MalateshPatil commented Jan 9, 2018

var data = [ { name: "Test 1", age: 13, average: 8.2, approved: true, description: "using 'Content here, content here' " }, { name: 'Test 2', age: 11, average: 8.2, approved: true, description: "using 'Content here, content here' " }, { name: 'Test 4', age: 10, average: 8.2, approved: true, description: "using 'Content here, content here' " }, ];

If I don't want to convert age property to csv. Is there any way?

@masscrx
Copy link

masscrx commented Jan 12, 2018

You can filter data before exporting to csv ?

@ErikJungnickel
Copy link

You could use the map function to create an array of new objects.

let data = data.map(d => { return { name: d.name, average: d.average, ... }; });

@lopenchi
Copy link
Contributor

I have made a PR.
In the new version you have to send an array of the keys you want to export in csv.

new Angular2Csv(data, filemame, {keys: keys});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants