aufgeräumt
This commit is contained in:
BIN
mp3/.DS_Store
vendored
Normal file
BIN
mp3/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
mp3/Hej.mp3
BIN
mp3/Hej.mp3
Binary file not shown.
BIN
mp3/Ja.mp3
BIN
mp3/Ja.mp3
Binary file not shown.
BIN
mp3/Nej.mp3
BIN
mp3/Nej.mp3
Binary file not shown.
BIN
mp3/Tack.mp3
BIN
mp3/Tack.mp3
Binary file not shown.
BIN
mp3/Ursäkta.mp3
BIN
mp3/Ursäkta.mp3
Binary file not shown.
BIN
mp3/bra.mp3
BIN
mp3/bra.mp3
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
mp3/dåligt.mp3
BIN
mp3/dåligt.mp3
Binary file not shown.
BIN
mp3/elva.mp3
BIN
mp3/elva.mp3
Binary file not shown.
BIN
mp3/ett.mp3
BIN
mp3/ett.mp3
Binary file not shown.
BIN
mp3/fem.mp3
BIN
mp3/fem.mp3
Binary file not shown.
BIN
mp3/femton.mp3
BIN
mp3/femton.mp3
Binary file not shown.
BIN
mp3/fjorton.mp3
BIN
mp3/fjorton.mp3
Binary file not shown.
BIN
mp3/fråga.mp3
BIN
mp3/fråga.mp3
Binary file not shown.
BIN
mp3/fyra.mp3
BIN
mp3/fyra.mp3
Binary file not shown.
BIN
mp3/gammal.mp3
BIN
mp3/gammal.mp3
Binary file not shown.
Binary file not shown.
BIN
mp3/namnet.mp3
BIN
mp3/namnet.mp3
Binary file not shown.
BIN
mp3/nere.mp3
BIN
mp3/nere.mp3
Binary file not shown.
BIN
mp3/nio.mp3
BIN
mp3/nio.mp3
Binary file not shown.
BIN
mp3/nitton.mp3
BIN
mp3/nitton.mp3
Binary file not shown.
BIN
mp3/pengarna.mp3
BIN
mp3/pengarna.mp3
Binary file not shown.
Binary file not shown.
BIN
mp3/sex.mp3
BIN
mp3/sex.mp3
Binary file not shown.
BIN
mp3/sexton.mp3
BIN
mp3/sexton.mp3
Binary file not shown.
BIN
mp3/sju.mp3
BIN
mp3/sju.mp3
Binary file not shown.
BIN
mp3/tio.mp3
BIN
mp3/tio.mp3
Binary file not shown.
BIN
mp3/tjugo.mp3
BIN
mp3/tjugo.mp3
Binary file not shown.
BIN
mp3/tolv.mp3
BIN
mp3/tolv.mp3
Binary file not shown.
BIN
mp3/tre.mp3
BIN
mp3/tre.mp3
Binary file not shown.
BIN
mp3/tretton.mp3
BIN
mp3/tretton.mp3
Binary file not shown.
BIN
mp3/två.mp3
BIN
mp3/två.mp3
Binary file not shown.
BIN
mp3/ung.mp3
BIN
mp3/ung.mp3
Binary file not shown.
BIN
mp3/uppe.mp3
BIN
mp3/uppe.mp3
Binary file not shown.
BIN
mp3/åtta.mp3
BIN
mp3/åtta.mp3
Binary file not shown.
Reference in New Issue
Block a user