Skip to content

Instantly share code, notes, and snippets.

@nehalvpatel
Created March 20, 2018 18:58
Show Gist options
  • Select an option

  • Save nehalvpatel/47161f18aad809c5954775c1daa82598 to your computer and use it in GitHub Desktop.

Select an option

Save nehalvpatel/47161f18aad809c5954775c1daa82598 to your computer and use it in GitHub Desktop.
Rudimentary script to parse and format MindTap flashcards for Quizlet
import json, re, sys
from bs4 import BeautifulSoup
input_file = sys.argv[1]
with open(input_file, encoding="utf8") as json_handle:
data = json.load(json_handle)
for card in data[0]:
term_html = card['term']
term_soup = BeautifulSoup(term_html, "html.parser")
term = term_soup.get_text()
definition_html = card["definition"]
definition_soup = BeautifulSoup(definition_html, "html.parser")
definition = definition_soup.get_text()
print("%s~~~~%s^^^^" % (term, definition))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment