Re: [Tutor] arrangement of datafile

2014-01-10 Thread Albert-Jan Roskam
Ok, it's clear already that the OP has a csv file so the following is OFF-TOPIC. I was reading Python Cookbook and I saw a recipe to read fixed width files using struct.unpack. Much shorter and faster (esp. if you use compiled structs) than indexing. I thought this is a pretty cool approach: h

Re: [Tutor] arrangement of datafile

2014-01-10 Thread Amrita Kumari
Hi Peter, Thankyou very much for your kind help. I got the output like the way I wanted (which you have also shown in your output). I really appreciate your effort. Thanks for your time. Amrita On Thu, Jan 9, 2014 at 8:41 PM, Peter Otten <__pete...@web.de> wrote: > Amrita Kumari wrote: > > > O

Re: [Tutor] arrangement of datafile

2014-01-09 Thread Peter Otten
Amrita Kumari wrote: > On 17th Dec. I posted one question, how to arrange datafile in a > particular fashion so that I can have only residue no. and chemical > shift value of the atom as: > 1 H=nil > 2 H=8.8500 > 3 H=8.7530 > 4 H=7.9100 > 5 H=7.4450 > > Peter has replied to this mail

Re: [Tutor] arrangement of datafile

2013-12-27 Thread Evans Anyokwu
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

Re: [Tutor] arrangement of datafile

2013-12-27 Thread Andreas Perstinger
[Please don't top-post and trim the quoted message to the essential. See http://www.catb.org/~esr/jargon/html/T/top-post.html ] Amrita Kumari wrote: >My data file is something like this: > [SNIP] >can you suggest me how to produce nested dicts like this: [SNIP] What's the current version of your

Re: [Tutor] arrangement of datafile

2013-12-27 Thread Amrita Kumari
Hi, My data file is something like this: 1 GLY HA2=3.7850 HA3=3.9130 2 SER H=8.8500 HA=4.3370 N=115.7570 3 LYS H=8.7530 HA=4.0340 HB2=1.8080 N=123.2380 4 LYS H=7.9100 HA=3.8620 HB2=1.7440 HG2=1.4410 N=117.9810 5 LYS H=7.4450 HA=4.0770 HB2=1.7650 HG2=1.4130 N=115.4790 6 LEU H=7.6870 HA=4.2100 HB2

Re: [Tutor] arrangement of datafile

2013-12-25 Thread Dave Angel
On Wed, 25 Dec 2013 16:17:27 +0800, Amrita Kumari wrote: I tried these and here is the code: f=open('filename') lines=f.readlines() new=lines.split() That line will throw an exception. number=int(new[0]) mylist=[i.split('=')[0] for i in new] one thing I don't understand is why you a

[Tutor] arrangement of datafile

2013-12-25 Thread Amrita Kumari
Hi, On 17th Dec. I posted one question, how to arrange datafile in a particular fashion so that I can have only residue no. and chemical shift value of the atom as: 1 H=nil 2 H=8.8500 3 H=8.7530 4 H=7.9100 5 H=7.4450 Peter has replied to this mail but since I haven't subscribe to the

Re: [Tutor] arrangement of datafile

2013-12-17 Thread Peter Otten
Amrita Kumari wrote: > Hi, > > I am new in programming and want to try Python programming (which is > simple and easy to learn) to solve one problem: in which > I have various long file like this: > > 1 GLY HA2=3.7850 HA3=3.9130 > 2 SER H=8.8500 HA=4.3370 N=115.7570 > 3 LYS H=8.7530 HA=4.0340 HB

[Tutor] arrangement of datafile

2013-12-17 Thread Amrita Kumari
Hi, I am new in programming and want to try Python programming (which is simple and easy to learn) to solve one problem: in which I have various long file like this: 1 GLY HA2=3.7850 HA3=3.9130 2 SER H=8.8500 HA=4.3370 N=115.7570 3 LYS H=8.7530 HA=4.0340 HB2=1.8080 N=123.2380 4 LYS H=7.9100 HA=3.