Table update

2007-08-28 Thread Ahmed, Shakir

I am trying to use python script to update a table by incremental value
based on struc_No but having problem to get right result on the value
field for the 3rd and 4th same number of struc_no. 

I need to update the Value field only with the incremental value of 15
or so

Any help is highly appreciated.

Thanks
Shak



Input table or source table

ID  struc_idStruc_NoValue   
1   ABC 100110  
2   EFJ 100515  
3   HIK 100310  
4   ILK 100510  
5   PIO 10018   
6   TIN 100112  
7   MNO 100111  
8   POW 100318  


Output Table

ID  struc_idStruc_NoValue   Added value
1   ABC 100125  15
2   EFJ 100530  15
3   HIK 100325  15
4   ILK 100540  30
5   PIO 100138  30
6   TIN 100157  45
7   MNO 100171  60
8   POW 100348  30


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Table update

2007-08-28 Thread [EMAIL PROTECTED]
On Aug 28, 2:57 pm, Ahmed, Shakir [EMAIL PROTECTED] wrote:
 I am trying to use python script to update a table by incremental value
 based on struc_No but having problem to get right result on the value
 field for the 3rd and 4th same number of struc_no.

 I need to update the Value field only with the incremental value of 15
 or so

 Any help is highly appreciated.

 Thanks
 Shak

 Input table or source table

 ID  struc_idStruc_NoValue
 1   ABC 100110
 2   EFJ 100515
 3   HIK 100310
 4   ILK 100510
 5   PIO 10018
 6   TIN 100112
 7   MNO 100111
 8   POW 100318

 Output Table

 ID  struc_idStruc_NoValue   Added value
 1   ABC 100125  15
 2   EFJ 100530  15
 3   HIK 100325  15
 4   ILK 100540  30
 5   PIO 100138  30
 6   TIN 100157  45
 7   MNO 100171  60
 8   POW 100348  30


Well you certainly won't learn anything if you don't at least try to
solve the problem.
 file = open('Somefile', 'r').readlines()
 for line in file:
... x = line.split()
... if not x[3] == Value:
... print int(x[3]) + 15

I'm sure you can take it from here. Hope it helps.

Best regards

Jeffrey van Aswegen

-- 
http://mail.python.org/mailman/listinfo/python-list