[EMAIL PROTECTED] wrote:
I would like to read this file as a record.
I can do this in perl by defining a record seperator;
is there an equivalent in python?

Depending on your exact use case, you may also get some mileage out of using the csv module with a custom delimeter.


Py> from csv import reader
Py> parsed = reader(demo, delimiter='|')
Py> for line in parsed: print line
...
['a', 'b', 'c', 'd']
['1', '2', '3', '4']

Cheers,
Nick.

P.S. 'demo' was created via:
Py> from tempfile import TemporaryFile
Py> demo = TemporaryFile()
Py> demo.write(txt)
Py> demo.seek(0)
Py> demo.read()
'a|b|c|d\n1|2|3|4'
Py> demo.seek(0)

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to