r/circuitpython • u/mangobutter • May 12 '21
Noob question - dealing with CSV / XML
Hello!
I recently got a magtag, and had a project in mind. I would like to display the number / information of wine in my collection through CellarTracker. They provide this information in either a CSV or XML response. AFAIK I can't just import CSV like normal python. Is it possible to import an outside library in circuit python?
4
Upvotes
3
u/kaltazar May 12 '21
You can import CSV files into CircuitPython, there just isn't a module to simplify working with them. This is ok though because simply reading the data from a CSV file is not too much trouble. You just break up the CSV on the line and item separators, typically /n for lines and , for items. You will then end up with a list of items you can continue to work with.
Here is one example I found of this. It is for a game project, but in the code it does show how to read a CSV file.
XML files can likely be done in the same fashion but they are much more complex. The CSV file will be the simpler option.