# Postman Pre-Request Script to Read Variables from CSV file and Append to JSON Body

**URL:** <https://community.postman.com/t/postman-pre-request-script-to-read-variables-from-csv-file-and-append-to-json-body/36603>\
**Category:** Help Hub\
**Tags:** variables, json, python, javascript\
**Created:** [June 27, 2022, 7:47pm UTC](https://community.postman.com/t/postman-pre-request-script-to-read-variables-from-csv-file-and-append-to-json-body/36603 "2022-06-27T19:47:55Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 27, 2022, 9:04pm UTC](https://community.postman.com/t/postman-pre-request-script-to-read-variables-from-csv-file-and-append-to-json-body/36603/5 "2022-06-27T21:04:10Z")

</div>

I think this is what you are looking for;  
Being able to manipulate the iterations based on the total row count in your CSV.

> [@Perform actions on the basis of iteration count in Collection Runner](https://community.postman.com/t/perform-actions-on-the-basis-of-iteration-count-in-collection-runner/2739/2):
>
> Hey @gherghinoiu, the good news is that it’s solvable! So, if you scroll down the docs - [https://www.getpostman.com/docs/v6/postman/scripts/postman\_sandbox\_api\_reference](https://www.getpostman.com/docs/v6/postman/scripts/postman_sandbox_api_reference) You’ll see that in the pm.info object, there’s a property called as iterationCount which is the total number of iterations that are scheduled to run. Now, Total number of iterations === Number of rows in your CSV File Also, instead of using the response\_array.length you can use another property of the pm.info object viz. p…

If it’s not, let me know… I may have misunderstood your need.

---

_[View the full topic](https://community.postman.com/t/postman-pre-request-script-to-read-variables-from-csv-file-and-append-to-json-body/36603)._
