aa Flashcards
Term
Definition
’)
for row in rows:
if ‘
Read text from clipboard
’ in row:
term, definition = row.split(‘,’, 1) # Split only once to avoid ValueError
flashcards.append((term.strip(), definition.strip()))
else:
print(“Error parsing flashcard:”, row)
return flashcards
def export_to_csv(flashcards, filename):
with open(filename, ‘w’, newline=’’) as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow([‘Term’, ‘Definition’])
for card in flashcards:
csvwriter.writerow(card)
clipboard_text = pyperclip.paste()
flashcards = parse_flashcards(clipboard_text)
export_to_csv(flashcards, ‘flashcards.csv’)
print(“Flashcards exported to flashcards.csv”)