# Loading variables from csv file

**URL:** <https://forum.katalon.com/t/loading-variables-from-csv-file/57338>\
**Category:** Bug Report\
**Tags:** katalon-recorder\
**Created:** [August 10, 2021, 8:30pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338 "2021-08-10T20:30:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenn\_remar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/glenn_remar/32/16103_2.png) [@glenn\_remar](https://forum.katalon.com/u/glenn_remar)\
**Post date:** [August 10, 2021, 8:30pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/1 "2021-08-10T20:30:24Z")

</div>

I tried to put all variables for different test cases into 1 csv with different variable names. It was a single username and password for each test case. In each test case, I call loadVars with the filename at the beginning and at the end of the test case, I call endLoadVars. The first test case runs fine. The second test case runs fine but then it tries to run again with blank username but the password is filled in. I also tried to put the variables into separate files. I saw the same behavior.

---

<div class="post-metadata">

**Author:** ![tientt1938](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/tientt1938/32/16104_2.png) [@tientt1938](https://forum.katalon.com/u/tientt1938)\
**Post date:** [August 11, 2021, 2:05am UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/2 "2021-08-11T02:05:07Z")

</div>

Hey @glenn_remar,  
Can you share your saved file and your csv file?

---

<div class="post-metadata">

**Author:** ![glenn\_remar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/glenn_remar/32/16103_2.png) [@glenn\_remar](https://forum.katalon.com/u/glenn_remar)\
**Post date:** [August 11, 2021, 3:45pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/3 "2021-08-11T15:45:32Z")

</div>

I removed url and username and passwords. I could combine 2 users into one file to see if that fixes but they go to different websites after logging in. This works for the first test case for the first user. For the second test, it works for the second user but then tries to go in again with no username and repeats the password. I am using different csv files and different variable names but otherwise the steps are the same.

loadVars|env.csv  
open|url  
type|id=userNameInputBox|${APP\_USERNAME}  
type|id=passwordInputBox|${APP\_PASSWORD}  
click|id=\_cbdLogOnOff  
endLoadVars

where url is the url to the site.

env.csv  
APP\_USERNAME,APP\_PASSWORD  
NotMyUserName,NotMyPassword

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [August 12, 2021, 4:46am UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/4 "2021-08-12T04:46:29Z")

</div>

Hi @glenn_remar, It would be great if you can upload the files since it would help us reproduce this issue faster! You can send it in a private topic to me and @tientt1938 if you’re not comfortable with sharing data publicly.

---

<div class="post-metadata">

**Author:** ![glenn\_remar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/glenn_remar/32/16103_2.png) [@glenn\_remar](https://forum.katalon.com/u/glenn_remar)\
**Post date:** [August 12, 2021, 2:37pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/5 "2021-08-12T14:37:49Z")

</div>

I will make sure that the issue somewhere else in the recording. And I will see if I can reproduce with information that is public.

---

<div class="post-metadata">

**Author:** ![glenn\_remar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/glenn_remar/32/16103_2.png) [@glenn\_remar](https://forum.katalon.com/u/glenn_remar)\
**Post date:** [August 12, 2021, 3:32pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/6 "2021-08-12T15:32:26Z")

</div>

I cannot share krecorder files or zip file from work. But here is example. Can loadVars not run just once or do I not understand how to supply variables in csv file?

I have one variable with 1 instance. But it actually went through script twice. Second time variable was empty.

I can recreate at home and post if you cannot see.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/7/a/7a679e550e20151525822d6eba4d93e14bb623ec.png)

google1.csv  
FIRST\_SEARCH\_TERM  
Katalon

---

<div class="post-metadata">

**Author:** ![tientt1938](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/tientt1938/32/16104_2.png) [@tientt1938](https://forum.katalon.com/u/tientt1938)\
**Post date:** [August 12, 2021, 4:40pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/7 "2021-08-12T16:40:03Z")

</div>

> [@glenn\_remar](#):
>
> I have one variable with 1 instance. But it actually went through script twice. Second time variable was empty.

Hi @glenn_remar,  
Make sure that there isn’t an empty line at the end of the CSV file.  
Otherwise, that empty line will be counted as a legal value for column FIRST\_SEARCH\_TERM

---

<div class="post-metadata">

**Author:** ![glenn\_remar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/glenn_remar/32/16103_2.png) [@glenn\_remar](https://forum.katalon.com/u/glenn_remar)\
**Post date:** [August 16, 2021, 1:13pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/8 "2021-08-16T13:13:44Z")

</div>

I looked at the file in editor that shows new line characters. There is not an extra row.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/1/d/1dabedc8bf344a38842d7e4bceac4144067138d9.png)

---

<div class="post-metadata">

**Author:** ![1968693027](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/1968693027/32/18174_2.png) [@1968693027](https://forum.katalon.com/u/1968693027)\
**Post date:** [August 18, 2021, 6:48am UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/9 "2021-08-18T06:48:17Z")

</div>

You need to use Notepad or other text editor to open, delete blank lines and save, this will not happen

---

<div class="post-metadata">

**Author:** ![glenn\_remar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/glenn_remar/32/16103_2.png) [@glenn\_remar](https://forum.katalon.com/u/glenn_remar)\
**Post date:** [August 20, 2021, 3:50pm UTC](https://forum.katalon.com/t/loading-variables-from-csv-file/57338/10 "2021-08-20T15:50:46Z")

</div>

I found that the last line of the csv file cannot have a CRLF. I removed the last carriage return after Katalon above and the test only ran once, not twice.
