parsing a dbIII file

korovev76 at gmail.com korovev76 at gmail.com
Wed Aug 8 11:15:41 EDT 2007


On 7 Ago, 17:47, "Jerry Hill" <malaclyp... at gmail.com> wrote:
> On 8/7/07, korove... at gmail.com <korove... 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


you all were right, I had to mention that I must put the datas in
mysql... So actually the best way to do it is with csv.reader: i tried
it and it works out!

thanx very much!




More information about the Python-list mailing list