Python script for adding number


 
Thread Tools Search this Thread
Top Forums Programming Python script for adding number
# 1  
Old 12-13-2012
Python script for adding number

Dear All

I am having following python script.



Code:
def read_output(file):
        inp=open(file, "r")
        row=map(lambda x: x.split(), inp.readlines())
        line=[]
        for r in row:
           f1, f2, f3, f4,  t  = r[0], int(r[1]), r[2], int(r[3]), float(r[4]) 
           line.append((f1, f2, f3, f4, t))
        return line





data=sys.argv[1]

RECEPTOR=[ "2", "3", "R", "A", "C", "H", "B"]


line=read_output_openeye(data)

#print RECEPTOR[0]

text=len(line)
r=0
r1=0


for j in RECEPTOR:
  for i in range(30):
    r=r+1
    if r>210:
       r=0
       r=r+1

    for k in line:
       f1, f2, f3, f4, t =k
       if f1==j and f2==i:
                  r1=r1+1
                  if r1>210:
                       r1=0
                       r1=r1+1
                  print f1,"   ", f2, "   ", f3,"   ",  f4, "   ",  r, "   ",   r1, "  ", t

In this program, it adds up the number (+1) if r and r1 starts from 0 upto 210.

I am facing problem in modifying the program.

In my input r starts from "1" instead of "0". SO i want to modify the program such that it starts adding (+1) after 30 for r.

Kindly advice.

Many Thanks
Balaji
# 2  
Old 12-18-2012
Not sure, r goes up by one but you want it to go up by one at 30 too?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

How to execute python script on remote with python way..?

Hi all, I am trying to run below python code for connecting remote windows machine from unix to run an python file exist on that remote windows machine.. Below is the code I am trying: #!/usr/bin/env python import wmi c = wmi.WMI("xxxxx", user="xxxx", password="xxxxxxx")... (1 Reply)
Discussion started by: onenessboy
1 Replies

2. Shell Programming and Scripting

Adding number in one column

Hello I have something like this a 1 b 1 c 1 d 1 e 1 This is inside 1.dat and this is what I am trying to get a 2 b 2 c 2 d 2 e 2 (4 Replies)
Discussion started by: jeo_fb
4 Replies

3. Programming

Python Count Number Of Occurence

Hello, I have a programming assignment to count number of occurrences of hours in particular file. Below is the code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" largest = None fh = open(fname) counts = dict() test = list() for line in fh: ... (2 Replies)
Discussion started by: infinitydon
2 Replies

4. UNIX for Dummies Questions & Answers

Maximum number of data in Python

Hi all, I would like to save my output data in two columns. I tried print(x,y) but have two problems: 1. There are ~10000 values for each x and y, but the intermediates are omitted; 2. I'd like to list data in two columns instead of two arrays (BTW, it's fine as I can format it using other... (3 Replies)
Discussion started by: sxiong
3 Replies

5. Shell Programming and Scripting

script for adding page number before page breaks

Hi, If there is an expert that can help: I have many txt files that are produced from pdftotext that include page breaks the page breaks seem to be unix style hex 0C. I want to add page numbers before each page break as in : Page XXXX Regards antman (9 Replies)
Discussion started by: antman
9 Replies

6. Shell Programming and Scripting

adding a number with sed or awk.

Hi.. I have this delicate problem..:wall: I have this huge ldif file with entry's like this example below.. And I need to change the following entrys. telephoneNumber: emNotifNumber: billingnumber= BillingNumber: Al these entrys has a number like 012345678 and it needs to add one more... (15 Replies)
Discussion started by: pelama
15 Replies

7. UNIX for Dummies Questions & Answers

Adding Sequence Number to file

Hi All, I need to create a script which checks for a particular file for eg.kumar1.txt. If kumar1.txt is already exist the script should increment the file name as kumar2.txt and so on. Please Advise. Thanks & Regards, Kumar66 (2 Replies)
Discussion started by: kumar66
2 Replies

8. Shell Programming and Scripting

Python String <--> Number

My question is so simple: A = raw_input("A ") if A == '56': VAR = (A + 54)/13 else: print "other operations" if I write in input 5656565656 i want to make some arithmetic operations if the first input is 56XXX but the output is TypeError: cannot concatenate 'str' and... (2 Replies)
Discussion started by: kazikamuntu
2 Replies

9. Shell Programming and Scripting

merging line and adding number

I having file below o/p ibapp311dg,,20480,s,,,,,,,,, test,,20480,s,,,,,,,,, test,,20480,s,,,,,,,,, ibapp311dg,,20480,s,,,,,,,,, I want to to chk unique word line in the first field seperated by , as well as addup corressponding the number in field for each unique word like ibapp311dg... (8 Replies)
Discussion started by: tarunn.dubeyy
8 Replies

10. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies
Login or Register to Ask a Question