Q:

import cell value from xlsx to python variable for all rows

I want to use Openpyxl to open an xlsx file. Cycle through all the cells in row A and and them to an object class called "Students" one by one.
Openpyxl opens file - works
Class "students" defined - works
when queried returns the right max row - works
I know i need to create a loop which cycles through the rows to reach the last one but im not sure how to approach it.
something along the lines of:
for row in rows:
   Student(student_id = 'A(whatever the row number is).value)
   increase row number by one

A:

This way was much better. Ditch Openpyxl, open it from a csv file.
In the csv file I have rows each individual bit of information in columns A,B,C,D,E
eg. A1 = Potter, Harry  B1 = Potter C1 = Harry... etc
import csv

#sorts all the student data into a class
class Students():
    def __init__(self,student_id, first_name,second_name,student_parent,parent_email):

        self.student_id = student_id
        self.first_name = first_name
        self.second_name = second_name
        self.student_parent = student_parent
        self.parent_email = parent_email

    def __repr__(self):
        return self.student_id + " " + self.first_name + " " +self.second_name + " " + self.student_parent + " " + self.parent_email

student_list = []

#opens the csv file, takes out the information and saves them in the Student Class
student_file = open('student_list.csv')
student_file_reader = csv.reader(student_file)
for row in student_file:
    row_string = str(row)
    row_parts1,row_parts2,row_parts3,row_parts4,row_parts5 = row_string.split(',')
    student_list.append(Students(row_parts1,row_parts2,row_parts3,row_parts4,row_parts5))

...and there you have it, all in formation in objects within a list perfect.

