r/learnpython • u/Nythious • Feb 20 '21
What are you having difficulty learning or are currently struggling to learn?
I'm curious what the community here has difficulty with when it comes to learning Python. Partly because I want to see if the more experienced community here (or myself) can help point you into the right direction. . . but also because I'm trying to come up with video tutorial ideas for future content and would love to hear from Python learners what would be most useful to dedicate our time on.
I'm looking forward to hearing what you guys have to say!
417
Upvotes
2
u/MaraudingAvenger Feb 21 '21
You can use
xml.etree.ElementTreeto parse and navigate XML. Check out the docs for some good code examples.Changing what you parse into sqlite syntax is a matter of string formatting -- I highly recommend getting familiar with the string formatting mini-language if you have a chance -- that is everything after the colon in the squirrelly brackets in:
I assume you're interacting with your sqlite database using the sqlite3 library (or maybe pandas).
A JSON is almost exactly a python dictionary, written out in a string, the way it looks when you write one out in your code. The
jsonlibrary can parse json strings coming in into python dicts (json.loads), or dump python dicts out into json strings (json.dumps).Basically combining all of those things should give you the ability to go from huge XML files to sqlite to JSONs! If you want to share more specifics I could maybe help point the way.
As for stardict files, from what I can gather from https://en.wikipedia.org/wiki/DICT, the format looks pretty approachable -- you should probably use a good regex combined with some string cleanup (probably also using regex) to extract definitions from the files.
Hopefully that's enough to get you at least some stuff to Google!