Converting a text file to a string?

Emile van Sebille emile at fenx.com
Sat Sep 1 18:10:12 CEST 2001


listedRecs = [rec.split('|') for rec in open('filename').xreadlines()]

HTH

--

Emile van Sebille
emile at fenx.com

---------
"eif" <eif at ukonline.co.uk> wrote in message
news:QC7k7.5474$QG.2234404 at monolith.news.easynet.net...
> can anyone  please help me out here? - im running a python cgi script that
> outputs a database in a text file format something that looks like this:
>
> 999347857||9/1/2001 at 13:37:37|016354|jim o
> shea|jim at mmu.ac.uk|126|0161025658
> 999347943||9/1/2001 at 13:39:03|223654|roy
> saberton|roy at mmu.ac.uk|201|0161236510
> 999347943||9/1/2001 at 13:39:03|223654|roy
> saberton|roy at mmu.ac.uk|201|0161236510
>
> I can open and read this file, but the problem is I want to convert this
> file into a list - in order to access and manipulate each individual
> element. can anyone tell me how to do this or am I going the wrong way
about
> the problem?
>
> cheers
>
>
>
>




More information about the Python-list mailing list