473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Table update


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_id Struc_No Value
1 ABC 1001 10
2 EFJ 1005 15
3 HIK 1003 10
4 ILK 1005 10
5 PIO 1001 8
6 TIN 1001 12
7 MNO 1001 11
8 POW 1003 18
Output Table

ID struc_id Struc_No Value Added value
1 ABC 1001 25 15
2 EFJ 1005 30 15
3 HIK 1003 25 15
4 ILK 1005 40 30
5 PIO 1001 38 30
6 TIN 1001 57 45
7 MNO 1001 71 60
8 POW 1003 48 30
Aug 28 '07 #1
1 1397
On Aug 28, 2:57 pm, "Ahmed, Shakir" <shah...@sfwmd.govwrote:
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_id Struc_No Value
1 ABC 1001 10
2 EFJ 1005 15
3 HIK 1003 10
4 ILK 1005 10
5 PIO 1001 8
6 TIN 1001 12
7 MNO 1001 11
8 POW 1003 18

Output Table

ID struc_id Struc_No Value Added value
1 ABC 1001 25 15
2 EFJ 1005 30 15
3 HIK 1003 25 15
4 ILK 1005 40 30
5 PIO 1001 38 30
6 TIN 1001 57 45
7 MNO 1001 71 60
8 POW 1003 48 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

Aug 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
6
by: Jeff Kowalczyk | last post by:
I need to adapt this an update statement to a general form that will iterate over multiple orderids for a given customerinvoiceid. My first concern is a form that will work for a given orderid,...
3
by: PAUL | last post by:
Hello, I have 2 datasets I am trying to update. The parent table seems to update fine but when I go update the chiled table I get an error message that says I need a related record in the parent...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
9
by: Oonz | last post by:
Hi Friends, How can we insert records in sorted order like consider a table No Name Phone 1 test1 12345 1 test1 23455 2 test2 68638
3
by: Shestine | last post by:
I am trying to add a column to a current table, with data in it. I am only learning, and i have no idea how to change this to make it work. Here is the script I have right now it, but what it does is...
1
by: adithi | last post by:
My Table Structure is: Table A Table B Table C colA -PK Col B-PK Col C-PK Col B-FK ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.