Python equivalent of Perl's Input Record Separator ?

remco boerma remco at tomaatnet.nl
Wed Feb 12 07:36:08 EST 2003


> I have a large file with records ending in ox0a 0x0a, the records also
> contain \n's

If the file is not to long you could use:

f  = file('filename')
sep = chr(0x0a) *2
records = file.read().split(sep)
f.close
print 'File has', len(records),'records'


Cheers
Remco




More information about the Python-list mailing list