I created a program to write a simple .csv (code below):
opencsv = open('agentstatus.csv', 'w')
a = csv.writer(opencsv)
data = [[agents125N],
[okstatusN],
[warningstatusN],
[criticalstatusN],
[agentdisabledN],
[agentslegacyN]]
a.writerows(data)
opencsv.close()
The .csv looks like this (it's with empty rows in the middle, but it's not a problem):
36111
96
25887
10128
7
398
Now I am trying to read the .csv and store each of this numbers in a variable, but without success, see below an example for the number 36111:
import csv
with open('agentstatus.csv', 'r') as csvfile:
f = csv.reader(csvfile)
for row in f:
firstvalue = row[0]
However, I get the error:
line 6, in <module>
firstvalue = row[0]
IndexError: list index out of range
Could you support me here?