# How i can check environmet from a csv?

**URL:** <https://community.postman.com/t/how-i-can-check-environmet-from-a-csv/11681>\
**Category:** Help Hub\
**Tags:** variables, collections\
**Created:** [April 2, 2020, 10:15am UTC](https://community.postman.com/t/how-i-can-check-environmet-from-a-csv/11681 "2020-04-02T10:15:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![emanuele1986](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@emanuele1986](https://community.postman.com/u/emanuele1986)\
**Post date:** [April 2, 2020, 10:15am UTC](https://community.postman.com/t/how-i-can-check-environmet-from-a-csv/11681/1 "2020-04-02T10:15:24Z")

</div>

Hi all,

i working with postman from a couple of days and it is very useful :).

I configured a collection like the image:

![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/e/1e7cfc91a1f94351b9bd19b5a50953be1121aea1.png)

it works fine and i can create user and role with mongo db api from a csv.

My question is, how i can check the environmet and execute the correct line from a csv? My csv is formatted like the screen:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/5/d551cd3fd02a58fcd789310aeb00893aaae1937e.png)

if i run collection with that csv postman create in all enviroment, DV and TS, the same object.  
If possibile to configure a control that get the environmet, ts and dv also from a new Column in csv:  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/a/aa98612f11aa64276031267e675c7e640640f8ef.png)

and than create object in the right environmet?

I just put into body request the json code and setup the variable on postman.

Here body json code(is the same in all request):

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/f/f0c1675b6164c910767fbd891e81202d4999fd0d.png)  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/d/db777a628afee1465bc5cc5add6219dabc7c77fc.png)

Thanks

---

<div class="post-metadata">

**Author:** ![SabriH](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@SabriH](https://community.postman.com/u/SabriH)\
**Post date:** [April 2, 2020, 10:15pm UTC](https://community.postman.com/t/how-i-can-check-environmet-from-a-csv/11681/2 "2020-04-02T22:15:15Z")

</div>

Hey @emanuele1986,

Welcome to the community!!

You’ll only be able to set **one** environment during a collection run. However, If I understood your request correctly you’d like to use the TS values for the TS folder and the DV values for the DV folder, is that correct?

In that case, I believe you should accomplish your desired outcome by using branching-looping to do so. I’ll reference the documentation here: [https://learning.postman.com/docs/postman/scripts/branching-and-looping/](https://learning.postman.com/docs/postman/scripts/branching-and-looping/)

You’d use fetch the data from the CSV file ( more information on how to do so here: [https://learning.postman.com/docs/postman/scripts/postman-sandbox-api-reference/#pmiterationdata](https://learning.postman.com/docs/postman/scripts/postman-sandbox-api-reference/#pmiterationdata) ) and the branching-looping would allow you to set your workflow for requests with the logic you’d like to establish.

Hopefully, this helps!

---

<div class="post-metadata">

**Author:** ![emanuele1986](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@emanuele1986](https://community.postman.com/u/emanuele1986)\
**Post date:** [April 3, 2020, 8:58am UTC](https://community.postman.com/t/how-i-can-check-environmet-from-a-csv/11681/3 "2020-04-03T08:58:12Z")

</div>

Hi @SabriH ,

yes is correct. I would like to use, from a unique csv, TS variable for TS folder, DV variables for a DV folder, etc…

I red that links but i don’t understand well. I tried to do some test with postman.setNextRequest(“nomaofmyrequest”), but it didn’t work well:

1. if i configure it on collection or folder in prerequisites script:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/a/abee213911f2070b26fbc974828b80658debcfa4.png)

it take only the first row of csv and after went in conflict(it try to create always firts row of csv)

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/e/e27defee8f28a5a75cd5791cbfede4c356490de3.png)

if i put it directly on request it create same object in ts and dv folder:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/6/d6a266ae17bf7d3a6004c198fae9af93e974cfa2.png)

Can you make please an example for branch looping and pmiterationdata for how i have to setup it?  
Excuse me for this request.

Thanks

---

<div class="post-metadata">

**Author:** ![SabriH](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@SabriH](https://community.postman.com/u/SabriH)\
**Post date:** [April 3, 2020, 8:09pm UTC](https://community.postman.com/t/how-i-can-check-environmet-from-a-csv/11681/4 "2020-04-03T20:09:38Z")

</div>

Hey @emanuele1986,

Just following up here. As requested, I’ve added a template here: [https://documenter.getpostman.com/view/10582367/SzYbxGw1?version=latest](https://documenter.getpostman.com/view/10582367/SzYbxGw1?version=latest) to hopefully illustrate. This isn’t a very in-depth example but hopefully will help demonstrate some of the possibilities regarding what you are trying to accomplish.

The CSV used in the example template was the following:  
 ![Screen Shot 2020-04-03 at 4.05.23 PM](https://us1.discourse-cdn.com/getpostman/original/3X/d/f/df0f56a3ef8f550b7e3b23945ba427e60ba3f183.png)

So for this example, a dummy request was set where we fetch data from the CSV ( in this case the environment variables ) and then set the next request accordingly depending on the value of the variable. You could then expand upon this example depending on your requirements.

Hopefully, this helps!

---

<div class="post-metadata">

**Author:** ![emanuele1986](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@emanuele1986](https://community.postman.com/u/emanuele1986)\
**Post date:** [April 9, 2020, 1:09pm UTC](https://community.postman.com/t/how-i-can-check-environmet-from-a-csv/11681/5 "2020-04-09T13:09:32Z")

</div>

Thanks for the example, i will try in the next days 🙂
