# How to use variables from the CSV file

**URL:** <https://community.postman.com/t/how-to-use-variables-from-the-csv-file/42640>\
**Category:** Help Hub\
**Tags:** tests, variables, csv\
**Created:** [January 6, 2023, 4:51am UTC](https://community.postman.com/t/how-to-use-variables-from-the-csv-file/42640 "2023-01-06T04:51:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NataliaMerkulova](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@NataliaMerkulova](https://community.postman.com/u/NataliaMerkulova)\
**Post date:** [January 6, 2023, 4:51am UTC](https://community.postman.com/t/how-to-use-variables-from-the-csv-file/42640/1 "2023-01-06T04:51:12Z")

</div>

Hi guys!  
Could you please help me with a DataDriven tests.

_My question_: I have a CSV file with the CommunitiesID that I need to use like a variable for a graphQL query.

 ![Screen Shot 2023-01-05 at 20.36.51](https://us1.discourse-cdn.com/getpostman/original/3X/5/5/55c4469c11a223bc153b72fc9642cecb5b193baa.png)

I added a pre-request scripts:

```auto

pm.environment.set("communitiesId", data.communitiesId);
let list = pm.info.iterationCount;
console.log(list);
pm.environment.set("Total_Records", list);

```

And this is my CSV file:

 ![Screen Shot 2023-01-05 at 20.39.00](https://us1.discourse-cdn.com/getpostman/original/3X/8/5/858d01b2b2a9619383316297343e028428a59f56.png)

And this is a console:

 ![Screen Shot 2023-01-05 at 20.44.19](https://us1.discourse-cdn.com/getpostman/original/3X/1/9/19bf1b6016e914468d6d83f745b7afa467bc62f5.png)

The response should look like this:

```auto
{
    "data": {
        "findOneCommunity": {
            "yglId": 1441860,
            "name": "Acuity Homecare LLC",
            "title": "Acuity Homecare LLC",
            "slug": "acuity-homecare-llc-1441860",
            "isApfm": true,
            "isCustomer": false,
            "batchDate": "2021-11-11T00:00:00.000Z",
            "amenities": []
        }
    }
}

```

Will appreciate your help

---

<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:** [May 6, 2025, 2:45pm UTC](https://community.postman.com/t/how-to-use-variables-from-the-csv-file/42640/2 "2025-05-06T14:45:50Z")

</div>

Closed on May 6, 2025, 2:45pm UTC


