def read(self, filename): """ Read a CSV file """ self.userList.clear() if os.path.exists(filename) is True: df = pandas.read_csv(filename) # print first 5 rows # print(df.head()) if self.debug: print("Columns:") print(df.columns.tolist()) print("\n") for index, row in df.iterrows(): user = User() try: user.setVorname(str(row['Vorname'])) user.setNachname(str(row['Nachname'])) user.setUsername(str(row['Username'])) user.setEmail(str(row['Email'])) user.setGruppe(str(row['Gruppe'])) self.userList.append(user) except Exception as ex: self.logger.error( "Parsing csv File Error, is the seperator , ?") print(ex) else: self.logger.error("File ./%s not found! - exit -" % filename)
def read(self, filename): """ Read a CSV file """ self.userList.clear() if os.path.exists(filename) is True: df = pandas.read_csv(filename) for index, row in df.iterrows(): user = User() try: user.setVorname(str(row['Vorname']).strip()) user.setNachname(str(row['Nachname']).strip()) user.setKlasse(str(row['Klasse']).strip()) self.userList.append(user) except Exception as ex: self.logger.error( "Parsing csv File Error, is the seperator , ?") print(ex) else: self.logger.error("File ./%s not found! - exit -" % filename)