I’m uploading data in a table, at each line I’m verifying that the part number already exist in the table, if it does not I’m trying to save the part number to an array to display at the end of the upload.
for line in file.readlines():
data = line.split(",")
if fpmi.db.runScalarQuery("SELECT part FROM test2 WHERE part = %s" % (data[0]), "manufacturing") == data[0]:
WRITES THE RECORD
else:
NS_part = data[0]
fpmi.gui.messageBox("Part Number Not Found "+str(NS_part[x]))
x=x+1
For part number I either get the number 4 or the number 8, any suggestions?
Maybe I’m not looking at this properly, when it comes to the use of arrays I’m assuming they will work the same as they do in C++.
I need to create an array (array_of_part_numbers = []) to store an unknown number of part numbers that do not currently exist in the table. I’m using an incremental counter to track the number of part numbers.
In the if statement when I find a part number that does not exist I set array_of_part_numbers = data [0], since data [0] contains the part number, counter=counter+1.
Then at the end of the program I want to use a loop to display the part numbers in a message box.
X=0
for x <= counter:
fpmi.gui.messageBox("Part Number Not Found" +str(array_of_part_numbers = [x])
Luckilly for you, you can do this in Python (in C++, you'd have to know the size of your array before you created it.)
I think this is where your code was falling apart. You don't want to set the array = data[0], you want to append data[0] into the array.
[quote="DB2"]
Then at the end of the program I want to use a loop to display the part numbers in a message box.
X=0
for x <= counter:
fpmi.gui.messageBox("Part Number Not Found" +str(array_of_part_numbers = [x])
Am I on the right track?[/quote]
I don't know, I can't tell. You're mixing cases here for your varable names (X != x), but the variable names have changed since you last posted, so I don't know whats going on. You also need to put your code in code blocks so that the indentation isn't lost, like this: