CSV File Support - LoadVars handling specific line in source file

I have another query, however, so far I have not yet solved this one either.

For Katalon Recorder I have got a script working that allows me to load a CSV file, fetch the variables and then parse variables/make selections based upon the contents of the data it has fetched.

At the moment when using LoadVars I have no control over which line number within the CSV it uses, or how long it will keep looping, so at present it only ever stops when it reaches the EOF.

I would like to be able to just load a specific line of the CSV file via Katalon Recorder if possible, so that I could have a theoretical scenario like so (like pseudocode but not…):

I have 2 files with 100 entries, I want to populate a form and submit it 100 times but with different values every time.

1. Set variable for maximum no. loops
2. Set variable for current line no.
3. Set it to loop until maximum no. loops
4. Open form on the page
5. Load CSV file 1
6. Populate field/make selection based on value from CSV file for Line 1
7. Close CSV file 1
8. Load CSV file 2
9. Populate another field/make a different selection based on value from CSV file for Line 1
10. Close CSV file 2
11. Add +1 to variable
12. Submit form
13. Check if loop threshold is met and if so end

At the moment I can do the above, however, for steps 5-7 and 8-10, it will repeat the same step over and over again for the single form field till it reaches EOF for File 1, then repeat this till it reaches EOF for File 2.

Meaning I’ll only be able to submit the form single set of values this way and every time it’ll be with the 100th value in both CSV files.

If there was a way to specify which line LoadVars used then every time the function was called, it would allow me to fetch the data for the specified line only and then continue.

Does anyone know any suggestions/workarounds for this?

If not, can Katalon please implement something so that the above is possible? :slight_smile:

Thank you for the question. In the case, instead of “loadVars” please use “storeCsv”. I made an example for you at https://gist.github.com/devalex88/ddc15ab8fa0bf7a54fc50cbb9b696cc5.

Thanks Alex, this looks like a far more controlled and cleaner way of doing this. Will see how I go in practice with implementing it (as a workaround I had just combined several data files into a single CSV and just pulled values from respective columns, but it still meant every time starting from line 0 and recursively going through it).