I already created a dynamic xml request payload and I'm pulling some data from CSV file. Now I'm having a hard time to convert csv rows and column to hashmap since I'm a bit new to Groovy scripting.
My .csv
looks like this
itemId, name, lastname
12345, n1, ln1
54321, n2, ln2
66666, n3, ln3
....
What I want to achieve is like this
{
"12345": [
" n1",
" ln1"
],
"54321": [
"n2",
"ln2"
] .............
}
This is my code:
def source = new File('1000items.csv').readLines()
def payload = [:]
source.takeRight(source.size() - 1).each { line ->
payload.put(line.split(',')[0], ----STUCK HERE----)
}
PS: I'm following this guide but I'm stuck at building the hashmap part
Jmeter SOAP parameterization with dynamically changing tag blocks
Just pass a List as the 2nd argument and fill it with the remaining values from the current line.
Something like:
source.takeRight(source.size() - 1).each { line ->
def entry = line.split(',')
payload.put(entry[0], [entry[1], entry[2]])
}
More information: