Parsing data from text file to python

OmPs torque.india at gmail.com
Sun Aug 9 23:25:10 EDT 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 gmail.com
    Cluster Name: o  b
    Contact No.: 12346971239
    Coming: Yes

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

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

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

    Name: Test User
    Email: testuser at yahoo.co.in
    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:
http://stackoverflow.com/questions/31911191/parsing-data-from-text-file-to-python


Regards,
Om Prakash Singh
Live Curious
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150810/a82aed87/attachment.html>


More information about the Python-list mailing list