Blog

Learning Python: Data Science (Day 2.5)

11. April 2019 | 1 minute read

Tags: tags

Just a quick update, because I found the time to reorder the data to a multi-layer dictionary (if this is how you call it in Python) which should be much nicer to get the information from.

It was actually pretty easy to achieve and just required some on-the-fly initialization for any new keys. With the new layout it is now possible to get a list of values (time stamps and damage values) directly for a given event at a target and with a certain spell. All the keys needed for accessing the data are gathered automatically on the first and only loop through the file for use later on.


TIL:

  • Why does every language has a different syntax for else if?!
...
for ... :
	if ... :
		...

                targetID = splitLine[5]
                targetName = splitLine[6]
                spellName = splitLine[10]
                damageValue = splitLine[29]
                if eventName not in logData.keys():
                        logData[eventName] = {}
                elif targetID not in logData[eventName].keys():
                        logData[eventName][targetID] = {}
                elif spellName not in logData[eventName][targetID].keys():
                        logData[eventName][targetID][spellName] = []
                else:
                        logData[eventName][targetID][spellName].append([timeStamp,damageValue])

...