0

I am trying to read the data from csv file that contails 1 row and 5 column using the following code

def __init__(self):
        super(data, self).__init__()
        global data
        if (data == None):
            with open('var.csv', 'r') as l:
                reader = csv.reader(l)
                data = list(reader)
def on_start(self):
            if len(data) > 0:
                self.my_value = data.pop()

My output is ('sample') and I want it to be sample

Tester
  • 53
  • 2
  • 7

1 Answers1

2

Change the last line from self.my_value = data.pop() to self.my_value = data.pop()[0].

But you could also use locust plugins csv reader: https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/csvreader_ex.py

Cyberwiz
  • 11,027
  • 3
  • 20
  • 40