Although I am aware that Python has modules for graphing and working tests on data, I am not familiar with those modules (matplotlib, numpy, scipy), and am intent on pursuing the use of Python script that outputs to a .csv file that I can then read from MS Excel, and work more comfortably with the tools there.
Here's a solution that I have chosen:
1. You have to use "import csv", which shouldn't be an issue since it comes packaged in the standard library.
2. Read http://docs.python.org/3/library/csv.html and maybe
http://yuji.wordpress.com/2008/05/14/python-basics-of-python-dictionary-and-looping-through-them/ and
http://www.python.org/dev/peps/pep-0305/
If that still doesn't provide enough information, there is this, which talks about how to write dictionaries to .csv format:
http://stackoverflow.com/search?q=python+dictwriter
3. Now, feeling solid with the information, I decide not to write dictionaries at all, but go a slightly different route. For me, for printing out a series of states, labeled with the elements, and that can hold a quantity seems much more a list application; rather, best is a 3 dimensional array that has Array1: Elements that exist at Array2: State at Array3 quantity, which, graphed, would give a nice representation of the data.
That, though, goes beyond what I'm trying to accomplish at the moment.
So, what I have to start with is a Dictionary, which, if you don't know Python, are un-ordered name-value pairs; rather { 'key' : 'value', 'key2' : 'value2', ... : ... , 'keyn' : 'value' }. In the simulation script, the keys are the name of elements.
To print out a row of names, followed by a row of their values, I came up with the following:
Now, this only accounts for a single state, but for what I'm doing, that's okay. If I want to create a 2D array, where states are represented on the y-axis, I would refactor like so:
Once this is ran, I just open the results.csv in MS Excel and can continue to work with the data there.


No comments:
Post a Comment