Newbie query - reading text file (with column headings) into dictionary

Terry Reedy tjreedy at udel.edu
Mon Dec 9 11:53:28 EST 2002


"Mike Meyer" <mwm at mired.org> wrote in message
news:x7lm2z3h86.fsf at guru.mired.org...

> "Terry Reedy" <tjreedy at udel.edu> writes:

> > "Mike Meyer" <mwm at mired.org> wrote in message
> > > slices the data in an unusual direction. If you sliced it the
other
> > > way - making each line an object, instead of each column - then
> > > accessing individual data elements is nearly identical: you just
swap
> > > the order of the subscripts. However, you're more likely to want
to
> > > deal with a line as an individual object than a column.

> > Fortran (at least in the past) slices arrays in this 'unusal
> > direction'.
> > It facilitates adding new columns (new = log(old),

> Adding new featuers to a class is easy: my.new = log(my.old).

If the table is 100 lines of 10 attributes, then the OP should do
whats easiest and clearest (for the language he is using).  If the
table is a million lines with a thousand attributes, then data
organization can make a big difference in performance.  Unfortunately,
the optimal organization (row versus column) depends on the operation.
So my point is that column organization can sometimes be a rational
choice.  With column organization, 'new=log(old)' requires
sequentially reading one of the thousand blocks and sequentially
writing one.  With row/object organization, 'my.new = log(my.old)'
requires reading and rewriting everything (slightly expanded).

Terry J. Reedy





More information about the Python-list mailing list