csvRead (file name) - Selenium IDE command

The purpose of csvRead is to read data from a CSV file. Each macro loop reads one line of the CSV file and makes the data in the available with the ${!COL1}, ${!COL2},... internal variables.

Important: To submit more than just the first line of the CSV file, you must start the macro with the LOOP button. Each loop reads one line of the CSV. The line read is based on the value of the ${!LOOP} counter variable. If you make the loop run from 5 to 10, it will read lines 5 to 10 from the CSV file. Another option is to embed the CSVRead command inside a while loop with the internal vars !csvReadStatus and !csvReadLineNumber as shown in the DemoCsvReadWithWhile demo macro.

CSV Manager: Import (load) and export (save) CSV files from the <em>UI.Vision RPA</em> extension
Use the CSV Manager tab to import (load) and export (save) CSV files to and from the UI.Vision RPA extension. Importing CSV files first is required because browser extensions can not read from the hard drive directly. But with our UI.Vision RPA FileAccess XModule the RPA software can read CSV directly, see the next paragraph:

Reading CSV files directly from the hard drive

If you have the UI.Vision RPA FileAccess XModule installed, you can switch the macro storage mode to Hard-Drive Storage. This will also redirect all CSV read and write operation directly to the hard drive. By default, CSV files are then stored in the UIvision/datasources folder. In other words: UI.Vision RPA reads CSV data then directly from files - and you no longer need to import CSV files before using them. This also allows to easily share macros, images and CSV files between team members.
Important: Note that you can not use absolute paths to the CSV file. The CSV file location must always be in the /datasources folder or its subfolders.

csvReadArray - import your CSV into an array

The csvReadArray | csvfile.csv | arrayname command allows you to import the complete data from the CSV file at once. csvReadArray reads all CSV data at once and stores it in a 2-dimensional Javascript array. You can then access each element of the array with ${myCSV[row][column]}. To save the content of an array, use csvSaveArray.

If you're not familiar with arrays in JavaScript, Codecademy offers a great training module for arrays. (Note that this course wasn't developed by and isn't associated with UI.Vision.)

Import CSV into RPA Selenium IDE
csvReadArray reads all CSV data at once and stores it in an array. Note the array index starts with 0 not 1.

How to view array content in RPA Selenium IDE
You can use the variable tab to view the content of any array.

csvReadArray example: See the DemoCsvSaveArray demo macro that is installed with UI.Vision RPA. It uses csvReadArray, too.

FAQ: How can I use commas inside the CSV file text (not as a separator)?

User question: UI.Vision RPA uses comma as a separator, but I need sometimes to use comma in the text (not as a separator); how can i do this?
Answer: Enclose the field in quotes, e.g. use field1,field2,"fi,e,ld3",field4. And to include a single quote symbol " in a field it will be encoded as "", and the whole field will become """".

csvRead Example

This short example below reads names from a CSV file called "user.csv" and then fills the data into a form using the ${COL1} and ${COL2} internal variable. The CSV file has to be loaded in the UI.Vision RPA extension on the CSV tab to the local browser storage, it is not read from file.

Command Target Pattern/Text
open https://ui.vision/
csvRead user.csv
type id=firstname ${!COL1}
type id=lastname ${!COL2}

!csvReadMaxRow - read the last line of a CSV file

In some cases you may need to now how many lines are in a CSV file, or you want to read the last (most recently added) line of a CSV file. In both cases the internal variable !csvReadMaxRow can help. After the first csvRead, this value is set the number of lines in the CSV. This the example below we use it to read the last line of from a CSV file called "user.csv". We do this by setting !csvReadLineNumber to csvReadMaxRow and then run csvRead again.

Command Target Pattern/Text
csvRead user.csv
store ${!csvReadMaxRow} !csvReadLineNumber
csvRead user.csv
type id=firstname ${!COL1}

Works in

UI.Vision RPA for Chrome, Firefox, Edge Selenium IDE

Related Demo Macros

DemoCsvReadWithWhile, DemoCsvSave, DemoCsvReadArray

See also

csvSave, storeEval, Web Automation Extension User Manual, Selenium IDE commands, Classic Firefox Selenium IDE.

Anything wrong or missing on this page? Suggestions?

...then please contact us.

<em>UI.Vision RPA</em> Selenium IDE for Chrome and Firefox - Web Test Automation
Subscribe to the UI Vision RPA software newsletter . We'll send you updates on new releases that we're working on.