# Retrieve values from a file for pre-request

**URL:** <https://community.postman.com/t/retrieve-values-from-a-file-for-pre-request/60095>\
**Category:** Help Hub\
**Tags:** pre-request, runner\
**Created:** [April 18, 2024, 3:48pm UTC](https://community.postman.com/t/retrieve-values-from-a-file-for-pre-request/60095 "2024-04-18T15:48:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JavierReyes](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@JavierReyes](https://community.postman.com/u/JavierReyes)\
**Post date:** [April 18, 2024, 3:48pm UTC](https://community.postman.com/t/retrieve-values-from-a-file-for-pre-request/60095/1 "2024-04-18T15:48:29Z")

</div>

Hi!

I’m running via a “runner” and need to retrieve a value from the input file .csv to manipulate it before the final execution.

My file has this information:

rut,data  
103023440,4455005039211100  
103023440,445528503929988

I need to retrieve only the first 6 characters from the “data” field:

var data = pm.iterationData.get(“data”);  
var slicedData = data.substring(0, 6);  
pm.environment.set(“sliced”, slicedData);

Then I can use it in the final request.

{{rut}}  
{{data}}  
{{sliced}}

But still, I’m unable to do it… the value isn’t retrieved from the file.

---

<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:** [April 18, 2024, 5:51pm UTC](https://community.postman.com/t/retrieve-values-from-a-file-for-pre-request/60095/2 "2024-04-18T17:51:53Z")

</div>

You can use the special data variable which will have a JSON representation of the current iteration\line in the CSV file.

Try the following…

```auto
console.log(data); // json representation of the current line of your CSV
console.log(data.data); // this should be your data column from the CSV file.
console.log(data.data.substring(0, 6));
pm.environment.set("sliced", data.data.substring(0, 6));

```

---

<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:** [May 18, 2024, 5:52pm UTC](https://community.postman.com/t/retrieve-values-from-a-file-for-pre-request/60095/3 "2024-05-18T17:52:23Z")

</div>

Closed on May 18, 2024, 5:52pm UTC

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