[Tutor] Parsing a multi-line/record text file

wolfrage8765 at gmail.com wolfrage8765 at gmail.com
Tue Nov 13 15:15:35 CET 2012


On Sun, Nov 11, 2012 at 6:01 AM, Marc <marc at marcd.org> wrote:

> **
>
> Hello,
>
> I am trying to parse a text file with a structure that looks like:
>
> [record: Some text about the record]
>
>         Attribute 1 = Attribute 1 text
>
>         Attribute 3 = Attribute 3 text
>
>         Attribute 4 = Attribute 4 text
>
>         Attribute 7 = Attribute 7 text
>
> [record: Some text about the record]
>
>         Attribute 1 = Attribute 1 text
>
> <SNIP>
>
> Etc…for many hundreds of records
>

It looks like a Config or INI file to me.  It is worth a try to see if
configparser is able to process the file, if it can you have a solution, if
not you only wasted a few minutes trying.

>  <SNIP>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121113/c9cd4fdd/attachment-0001.html>


More information about the Tutor mailing list