# Save response in CSV file via newman

**URL:** <https://community.postman.com/t/save-response-in-csv-file-via-newman/15508>\
**Category:** Help Hub\
**Tags:** csv, tests, collections, newman-project, reporter\
**Created:** [September 1, 2020, 2:57pm UTC](https://community.postman.com/t/save-response-in-csv-file-via-newman/15508 "2020-09-01T14:57:23Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 1, 2020, 9:43pm UTC](https://community.postman.com/t/save-response-in-csv-file-via-newman/15508/7 "2020-09-01T21:43:57Z")

</div>

It looks like using Newman as a library, rather than from the command line with a specific reporter is going to be the option here.

You can tap into the different events and extract the data you want from the response and feed this into a CSV file.

> **[GitHub - postmanlabs/newman: Newman is a command-line collection runner for...](https://github.com/postmanlabs/newman#newmanrunevents)**
>
> Newman is a command-line collection runner for Postman - GitHub - postmanlabs/newman: Newman is a command-line collection runner for Postman

The node ‘fs’ module will allow you to write the data into a file.

[https://nodejs.org/api/fs.html](https://nodejs.org/api/fs.html)

Just a hacky example piece of code and is not a finished or polished solution:

```auto
const newman = require('newman'),
      fs = require('fs')

newman.run({
  collection: '<Collection File>',
}).on('console', function (error, args) {
      fs.appendFileSync('./results.csv', args.messages, function (error) {
  })
})

```

Add this to your request:

```auto
let itemOne = "<location of value in the response>",
    itemTwo = "<location of value in the response>";

console.log(`\n${itemTwo},${itemOne}`)

```

This will save the console statements to a csv file, it has multiple limitations and you could do the same thing to get the dat via the `request` event and narrow it down to just a specific request but this was a quick hack 😃

---

_[View the full topic](https://community.postman.com/t/save-response-in-csv-file-via-newman/15508)._
