Files
UCS_Import_Python/first_try/output.py
2024-01-26 15:41:22 +01:00

39 lines
1.3 KiB
Python

import csv
# Zielformat: ${nachname};${vorname};HL070${SCHOOL}-${klasse};${recordID};1024;${ox_quota};${ox_context}
def create_output(path):
schule = input('Schule: ')
record_id = input('Record ID: ')
mail_quota = input('Mail')
ox_quota = input('OX Quota: ')
ox_context = input('OX Context: ')
data = []
with open(path, newline='', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile, delimiter=';')
for row in reader:
data.append((row[0].strip(), row[1].strip(), schule, record_id, mail_quota, ox_quota, ox_context))
csv_file_path = '../Data/output.csv'
with open(csv_file_path, 'w', newline='', encoding='utf-8') as csvfile:
csv_writer = csv.writer(csvfile, delimiter=';')
# Schreibe die Header-Zeile (optional)
# name;vorname;klasse;schuelerid;mailUserQuota;oxUserQuota;oxContext
csv_writer.writerow(['name', 'vorname', 'klasse', 'schuelerid', 'mailUserQuota', 'oxUserQuota', 'oxContext'])
# TODO UUID prüfen bzw generien
# Schreibe die Daten aus dem Array in die CSV-Datei
csv_writer.writerows(data)
print(f"CSV-Datei wurde erfolgreich erstellt: {csv_file_path}")
if __name__ == "__main__":
create_output('../Data/test_new.csv')
# TODO Leerzeilen löschen
# TODO Klassenname umformatieren - HL070**** Nummer einfügen