I’ve been working on how to make maps load using an xml file. I need a very simple format containing every planet’s name, position, size and if its a possible home planet.
Its not a lot of information I need to hold nor is it very complicated.
All I want to do is grab some information so I can then build a map of planets and systems. It shouldn’t be a big problem something quick were I can just assign values for the things I want.
Using CSV getting the information is fast and simple. XML, is a whole different story.
Lets take a look at why:
This is the code to get all the items in a line of a csv file:
for row in csvfile:
do stuff with the row
or for each column in every row:
for name, x, y, z in csvfile:
do stuff with name, x, y and z
Its a whole lot less complicated than something like this.
To be honest, I thought using the xml file would be just as simple.
Something along the lines of:
for planet in xmlfile:
name = planet.name
x = planet.x
if hasattr(planet, ‘home’)
home = planet.home
and so forth. Alas, that is not the case and instead I have to deal with something like this.
I like simplicity and frankly, xml in python looks ugly and overly complicated for my task. Thus CSV files is what I’ll be using for now.