Sorry I forgot to add tutor mailing list.....please help for the below.

---------- Forwarded message ----------
From: Amrita Kumari <amrita....@gmail.com>
Date: Fri, Jan 3, 2014 at 2:42 PM
Subject: Re: [Tutor] arrangement of datafile
To: Evans Anyokwu <onyx...@gmail.com>


Hi,

I have saved my data in csv format now it is looking like this:

2,ALA,C=178.255,CA=53.263,CB=18.411,,,,,,,,,,
3,LYS,H=8.607,C=176.752,CA=57.816,CB=31.751,N=119.081,,,,,,,,
4,ASN,H=8.185,C=176.029,CA=54.712,CB=38.244,N=118.255,,,,,,,,
5,VAL,H=7.857,HG11=0.892,HG12=0.892,HG13=0.892,HG21=0.954,HG22=0.954,HG23=0.954,C=177.259,CA=64.232,CB=31.524,CG1=21.402,CG2=21.677,N=119.998
6,ILE,H=8.062,HG21=0.827,HG22=0.827,HG23=0.827,HD11=0.807,HD12=0.807,HD13=0.807,C=177.009,CA=63.400,CB=37.177,CG2=17.565,CD1=13.294,N=122.474
7,VAL,H=7.993,HG11=0.879,HG12=0.879,HG13=0.879,HG21=0.957,HG22=0.957,HG23=0.957,C=177.009,CA=65.017,CB=31.309,CG1=21.555,CG2=22.369,N=120.915
8,LEU,H=8.061,HD11=0.844,HD12=0.844,HD13=0.844,HD21=0.810,HD22=0.810,HD23=0.810,C=178.655,CA=56.781,CB=41.010,CD1=25.018,CD2=23.824,N=121.098
9,ASN,H=8.102,C=176.695,CA=54.919,CB=38.674,N=118.347,,,,,,,,
10,ALA,H=8.388,HB1=1.389,HB2=1.389,HB3=1.389,C=178.263,CA=54.505,CB=17.942,N=124.124,,,,,
11,ALA,H=8.279,HB1=1.382,HB2=1.382,HB3=1.382,C=179.204,CA=54.298,CB=17.942,N=119.814,,,,,
12,SER,H=7.952,C=175.873,CA=60.140,CB=63.221,N=113.303,,,,,,,,
13,ALA,H=7.924,HB1=1.382,HB2=1.382,HB3=1.382,C=178.420,CA=53.470,CB=18.373,N=124.308,,,,,
------------------
---------------------
-------------------

with comma seperated:

I can read the file as

infile = open('inputfile.csv', 'r')

I can read each line through

data = infile.readlines()

I can split the line into a list of strings at comma occurences as

for line in data:
          csvline = line.strip().split(",")

after this please help me to guide how to proceed as I am new in
programming but want to learn python program.

Thanks,
Amrita


On 12/28/13, Evans Anyokwu <onyx...@gmail.com> wrote:
> One thing that I've noticed is that there is no structure to your data.
> Some have missing *fields* -so making the use of regex out of the
question.
>
> Without seeing your code, I'd suggest saving the data as a separated value
> file and parse it. Python has a good csv support.
>
> Get this one sorted out first then we can move on to the nested list.
>
> Good luck.
> Evans
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to