parsing a dbIII file

Jerry Hill malaclypse2 at gmail.com
Tue Aug 7 11:47:44 EDT 2007


On 8/7/07, korovev76 at gmail.com <korovev76 at gmail.com> wrote:
> I have to parse a file (that is a dbIII file) whose stucture look like
> this:
> |string|, |string|, |string that may contain commas inside|, 1, 2, 3, |
> other string|

The CSV module is probably the easiest way to go:

>>> data = "|string|, |string|, |string that may contain commas
inside|, 1, 2, 3, |other string|"
>>> import csv
>>> reader = csv.reader([data], quotechar="|", skipinitialspace=True)
>>> for row in reader:
	print row

['string', 'string', 'string that may contain commas inside', '1',
'2', '3', 'other string']

-- 
Jerry



More information about the Python-list mailing list