aufgeräumt

This commit is contained in:
Sven Riwoldt
2025-02-09 09:51:22 +01:00
parent 61f97c0397
commit c03c0e9c77
622 changed files with 671 additions and 607 deletions

BIN
mp3/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,5 @@
import genanki
import csv
import os
import csv, os, random
# Variablen
csv_datei = "LZMP3.csv" # CSV-Datei mit Fragen, Antworten und Audio-Dateien
@@ -42,11 +41,12 @@ my_model = genanki.Model(
""",
)
# CSV-Datei einlesen und Notizen erstellen
notes = [] # Liste für Notizen
karten_anzahl = 0
with open(csv_datei, "r", encoding="utf-8") as file:
reader = csv.reader(file, delimiter=";")
#next(reader) # Kopfzeile überspringen
next(reader) # Kopfzeile überspringen
for i, row in enumerate(reader, start=2):
if len(row) < 2: # Mindestens zwei Spalten notwendig
print(f"Warnung: Zeile {i} hat zu wenige Spalten und wird übersprungen: {row}")
@@ -58,19 +58,17 @@ with open(csv_datei, "r", encoding="utf-8") as file:
# MP3-Datei zur Medienliste hinzufügen, falls vorhanden
if audio_datei and os.path.exists(audio_datei):
media_files.append(audio_datei)
audio_html = f'[sound:{audio_datei}]' # MP3-Datei in Anki-Format
audio_html = f'[sound:{os.path.basename(audio_datei)}]' # MP3-Datei in Anki-Format
else:
audio_html = "" # Kein Audio
print (f"Warnung: Keine Audio-Datei gefunden für Frage: {frage}")
# Notiz erstellen
# Notiz erstellen und in Liste speichern
note = genanki.Note(
model=my_model,
fields=[frage.strip(), antwort.strip(), audio_html],
tags=["Audio"],
)
print(f"Frage: {frage}, Antwort: {antwort}, Audio: {audio_html}")
my_deck.add_note(note)
notes.append(note)
karten_anzahl += 1
if karten_anzahl == 0:
@@ -78,6 +76,13 @@ if karten_anzahl == 0:
else:
print(f"{karten_anzahl} Karten erfolgreich erstellt.")
# Notizen zufällig mischen
random.shuffle(notes)
# Gemischte Notizen zum Deck hinzufügen
for note in notes:
my_deck.add_note(note)
# Stapel exportieren mit Medien
package = genanki.Package(my_deck)
package.media_files = media_files # Medien hinzufügen

View File

@@ -0,0 +1,23 @@
import csv
import re
file = open('LZMP3.csv', 'w+')
file.close()
with open('LZ.csv', 'r', encoding='utf-8') as input_file, open('LZMP3.csv', 'w', encoding='utf-8',
newline='') as output_file:
reader = csv.reader(input_file, delimiter=';') # Tab als Trennzeichen
writer = csv.writer(output_file, delimiter=';') # Semikolon als Trennzeichen
for row in reader:
print(row)
row[0] = row[0].replace("!","").replace("?", "")
row[1] = row[1].replace("!", "").replace("?", "")
row[0] = re.sub(r" \.+", "", row[0])
row[1] = re.sub(r" \.+", "", row[1])
if len(row) >= 2:
column3 = (row[1]+".mp3").replace(" ", "_")
#column3 = re.sub(r" \.+", ".", column3)
writer.writerow([row[0], row[1], column3]) # Spalte 2 und 3 schreiben

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.