With ResourceHelper you can load the contents of .csv or .tsv files stored in Resources as an object. To use ResourceHelper, proceed as follows:
Add the file ResourceHelper.groovy to the Resources in your solution and set the path to /script_lib
For more details on managing files in your solution, see Resource File Manager.
/script_lib
Example for csv files:
def myResourceData = ResourceHelper.loadCSV("your_filename_here");
Example for tsv files:
def myResourceData = ResourceHelper.loadTSV("your_filename_here");
ResourceHelper assumes the first line contains the headers and those will be used as keys.
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]
]
Was this page helpful?