[Tutor] Best approach to sort data based on several criteria
Rick Pasotto
rick@niof.net
Mon Jul 21 12:00:03 2003
On Mon, Jul 21, 2003 at 11:44:44AM -0300, Jorge Godoy wrote:
>
> Hi.
>
> I have a huge amount of data that's stored in a file where each record
> is in a line made of 22 columns, and each column is separated from the
> other by a ';'.
>
> I need to show this data (some columns each time) sorted out
> accordingly to some columns (e.g. columns zero, one, five and six,
> each on a different view and in one of these views, I need to sort
> based on multiple keys).
>
> What's the best way to handle this situation?
>
> I thought about splitting these columns and sorting them, but maybe
> there's a more efficient way...
>
> Not to mention that some columns are strings and other are dates or
> numbers.
As another poster said, the easiest way is to convert to a database.
For that you might want to consider SQLite. There's a python module.
http://sourceforge.net/projects/pysqlite/
This would be much simpler and more portable than the heavier duty
databases like MySql.
On the other hand, awk may be all you need! :-)
--
"If you speak the truth, have a foot in the stirrup."
-- Turkish proverb
Rick Pasotto rick@niof.net http://www.niof.net