Hey I am trying to read data from a list that is from a CSV file
def Load(): #Loads data from the csv that can be stored in functions
global userdata
global user
userdata = []
f = open('userdata.csv','r')
data = csv.reader(f)
for row in data:
user = []
for field in row:
user.append(field)
userdata.append(user)
f.close()
This is the login function which I am looping over
def Login(): #Login function
global userdata
Load()
global user
print('Please now login to your account')
x = False
while x == False:
usernameLog = input('Please enter your username: ')
j = len(userdata)
for i in range(0,j):
if usernameLog == userdata [i][0]: #Validates username
print('Username accepted')
time.sleep(1)
My program successfully writes to the CSV but just doesn't read from it without throwing out this error. I might just be being stupid though.