# Postman pre request script,İmport CSV file data

**URL:** <https://community.postman.com/t/postman-pre-request-script-import-csv-file-data/53644>\
**Category:** Help Hub\
**Tags:** newman-project, variables, collections\
**Created:** [October 24, 2023, 8:26am UTC](https://community.postman.com/t/postman-pre-request-script-import-csv-file-data/53644 "2023-10-24T08:26:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guclugunduz](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@guclugunduz](https://community.postman.com/u/guclugunduz)\
**Post date:** [October 24, 2023, 8:26am UTC](https://community.postman.com/t/postman-pre-request-script-import-csv-file-data/53644/1 "2023-10-24T08:26:07Z")

</div>

Postman/Pre-request Script get csv file data and save as environment variable

When I do postmande run collection, I add the csv file, but I couldn’t manage to pull this data and save it to environment variables at the pre-request script stage.after that ı will use this varible from environment in my boddy section code to update data on the server.

console.log(price);

pm.environment.set(“istenenDeger”, price);

let lojistikmaliyeti = Number(price);

console.log(lojistikmaliyeti);

pm.environment.set(“Lojistik Maliyeti”, lojistikmaliyeti);

the code is as above. My first line is the part where I need to define the data I took from the csv file into the “price” object. I left the part where it pulls data from csv blank.

ı tryied pm.collectionvariables.get combination or fs library and split but ı didnt get right conclusion

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 24, 2023, 9:51am UTC](https://community.postman.com/t/postman-pre-request-script-import-csv-file-data/53644/2 "2023-10-24T09:51:39Z")

</div>

[Using CSV and JSON Data Files in the Postman Collection Runner | Postman Blog](https://blog.postman.com/using-csv-and-json-files-in-the-postman-collection-runner/)

The runner uses a special data dictionary based on the CSV headers, so to reference the values in the CSV file, it should just be data.headername.

For example…

```auto
console.log(data.price);

```

If you just console log the data object, it will show you all of your test data for that iteration as an object.

```auto
console.log(data);

```

This looks like it should be a one liner.

```auto
pm.environment.set(“Lojistik Maliyeti”, Number(data.price));

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [October 27, 2023, 9:52am UTC](https://community.postman.com/t/postman-pre-request-script-import-csv-file-data/53644/3 "2023-10-27T09:52:21Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
