On Wed, Oct 8, 2014 at 2:19 PM, Martin A. Brown <mar...@linux-ip.net> wrote: > > Good afternoon, > >>> If its not too big a task you could even convert the data >>> structure to JSON which is quite a close match to what you >>> have now and the json module will help you read/write >>> to them.
Looking at some examples of JSON-structured data, I see that I formatted my data very similarly, as Alan noted. Purely a lucky coincidence! > > I would agree with the JSON recommendation (until your data set grows to > more than 10GB in size). Also, if you are operating with JSON, you can add > elements and delete elements and the serialization bits don't care. This > makes it more dynamic than a typical csv/tsv format. The application still > has to know about the data type, of course. > My data files are rather small and should remain so, about 30 to 40 lines at the most. Definitely forever less than 100 lines for each file. This is because there are only so many human organs in the vicinity of our radiation treatments that we might want to track dose for. >> I am not seeing JSON listed among python's standard libraries for version >> 2.4.4. Is this something that has to be independently installed? > > > Yes. The json module was 'only' added in Python 2.6. If you wanted to > operate on JSON in Python 2.4, you had to use something called simplejson > [0]. According to this post [0], the standard library json module is a(n > older) release of the simplejson module. > I looked at [0] and it states that it is backwards compatible to version 2.5, which is one iteration higher than my lowest installed python version at work. They provide a link to an older simplejson that is from the python 2.2 era, but state that this should be done only as a last resort. > Anyway, when I found myself stuck in Python-2.4 land (on the stock Python > shipped with CentOS-5.x, for example), I often saw and wrote snippets like > this [1]: > > try: # -- if Python-2.6+, it's in STDLIB > import json > except ImportError: # -- Python-2.4, simplejson > import simplejson as json > > And, then the rest of the program can operate just the same, regardless of > which one you used. > Is there a typo on [0]? Will it in fact work for python 2.4? > > [0] https://pypi.python.org/pypi/simplejson/ > [1] > http://stackoverflow.com/questions/712791/what-are-the-differences-between-json-and-simplejson-python-modules > -- boB _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor