CSV Helper
With ResourceHelper you can load the contents of .csv or .tsv files stored in Resources as an object. To use ResourceHelper, proceed as follows:
Installation
Add the file ResourceHelper.groovy to the Resources in your solution and set the path to /script_lib
Usage
- Add your .csv or .tsv file to the resources and set the path to /script_lib. Populate a variable using the following code (replace 'your_filename_here' with the name of your file):
Example for csv files:
groovy
1def myResourceData = ResourceHelper.loadCSV("your_filename_here");
2Example for tsv files:
groovy
1def myResourceData = ResourceHelper.loadTSV("your_filename_here");
2ResourceHelper assumes the first line contains the headers and those will be used as keys.
Example
If your csv/tsv looks like this:
| Firstname | Lastname | 
|---|---|
| Buffy | Summers | 
| Omar | Little | 
| Ellen | Ripley | 
| Jack | Sparrow | 
The resulting object will be:
[
	[Firstname:Buffy, Lastname:Summers], 
    [Firstname:Omar, Lastname:Little], 
    [Firstname:Ellen, Lastname:Ripley], 
    [Firstname:Jack, Lastname:Sparrow]
]