Parsing data from text file to python

OmPs torque.india at
Mon Aug 10 05:25:10 CEST 2015

Hi All,

Please accept my apologies, if this similar question has been asked
earlier, I tried to search over the stack network and googled but couldn't
find relevant information, partly may be because I may not be able to
search effectively.

I have built a contact form which sends me email for every user
registration My question is more related to parsing some text data into csv
format. and I have received multiple users information in my mail box which
I had copied into a text file. The data looks like below.

    Name: testuser2
    Email: testuser2 at
    Cluster Name: o  b
    Contact No.: 12346971239
    Coming: Yes

    Name: testuser3
    Email: testuser3 at
    Cluster Name: Mediternea
    Contact No.: 9121319107
    Coming: Yes

    Name: testuser4
    Email: tuser4 at
    Cluster Name: Mediterranea
    Contact No.: 7892174896
    Coming: Yes

    Name: tuser5
    Email: tuserner5 at
    Cluster Name: River Retreat A
    Contact No.: 7583450912
    Coming: Yes
    Members Participating: 2

    Name: Test User
    Email: testuser at
    Cluster Name: RD
    Contact No.: 09833123445
    Coming: Yes
    Members Participating: 2

As can see the data contains some common fields and some fields which are
not present, I am looking for solution/suggestion on how I can parse this
data so under the heading Name, I will collect the name information under
that column, and similarly for other, the data with title "Members
Participating" I can just pick the nos and add it into excel sheet under
the same heading, incase for the user this information is not present, it
can just go blank.

Stackoverflow link to this question:

Om Prakash Singh
Live Curious
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list