Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Trying to import data from excel sheet and assign it to values of a class. I can get it to print the values, but cannot think of how to assign it to each individual attribute of the class newUser."""
- from openpyxl import load_workbook
- wb = load_workbook(filename='test.xlsx', use_iterators=True)
- ws = wb['accounts_needed'] # Sets ws to be iterable
- class newUser:
- def __init__(self, firstname, lastname, email, password, campus, teks_username, google_username, discovery_username ):
- self.firstname = firstname
- self.lastname = lastname
- self.email = email
- self.password = password
- self.campus = campus
- self.teks_username = teks_username
- self.google_username = google_username
- self.discovery_username = discovery_username
- for row in ws.iter_rows(row_offset=1):
- for cell in row:
- print(cell.value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement