Recommended data structure for newbie

manstey manstey at csu.edu.au
Tue May 2 23:28:36 EDT 2006


Hi,

I have a text file with about 450,000 lines. Each line has 4-5 fields,
separated by various delimiters (spaces, @, etc).

I want to load in the text file and then run routines on it to produce
2-3 additional fields.

I am a complete newbie to Python but I have the docs and done some
experimenting. But I'm not sure what sort of data structure I should be
creating.

Example:
gee fre asd[234
ger dsf asd[243
gwer af as.:^25a

what i want is
'gee' 'fre' 'asd' '[' '234'
'ger' dsf' asf' '[' '243'
'gwer' 'af 'as.:' '^' '25a

etc for 450,000 lines.

Then on the basis of information in 1 or more lines, I want to append
to each line new data such as

'gee' 'fre' 'asd' '[' '234' 'geefre2' '2344f'
'ger' dsf' asf' '[' '243' 'gerdsd' '2431'
'gwer' 'af 'as.:' '^' '25a 'gweraf' 'sfd2'

What do you recommend? I think it is some sort of list inside a list,
but I'm not sure. I know how to generate the new data but not how to
store everything both in memory and on disk.

Regards,
Matthew




More information about the Python-list mailing list