I know this is a stupid question but I just can't solve the error I get.
So I've got a file called: Profiles.txt, and I want to open it with python and read what's inside.
This is inside the file:
Main,Henk,Klaas
profile_name = 'Main'
First_name = 'Henk'
Last_name = 'Klaas'
It doesn't need to print this out^^, but I want the variables to have those values. But i get this:
So I've got a file called: Profiles.txt, and I want to open it with python and read what's inside.
This is inside the file:
Main,Henk,Klaas
with open('Profiles.txt', 'r') as file: reader = csv.reader(file, delimiter=',') for row in reader: profile_name = row[0] first_name = row[1] last_name = row[2] print(profile_name) print(first_name) print(last_name)So I want my code to return this:
profile_name = 'Main'
First_name = 'Henk'
Last_name = 'Klaas'
It doesn't need to print this out^^, but I want the variables to have those values. But i get this:
Error:Traceback (most recent call last):
File "FILEPATH", line 15, in <module>
profile_name = row[0]
IndexError: list index out of range
Does someone know how to fix this and how to give the variables the value I want them to have?