I couldn´t find a better place to ask my question. I am learning Python and trying to create a script as follows.
1) Should be able to search csv file.
2) Return entire row if match is found.
My csv:
Product,Scan,Width,Height,Capacity
LR,2999,76,100,17.5
RT,2938,37,87,13.4
If I search for 2938 for an example, entire row is returned as follows:
Product: RT
Scan: 2938
Width: 37
Height: 87
Capacity: 13,4
So far I have:
csvFile = getComponent().filePath
pos = csvFile.rfind('Desktop\\')
csvFile = csvFile[:pos] + 'programm\\products.csv'
myfile = open(csvFile)
myfile.seek(0)
for line in myfile.split('\n'):
data = line.split(',')
print data
if data[2] == agv_O_Cal.value and data[3] == agv_O_Mod.value:
print 'found: value = %s' %agv_O_Cal.value, agv_O_Mod.value
Product = data[5]
Scan = data[6]
Width = data[7]
Height = data[9]
Capacity = data[10]
print , Product, Scan, Width, Height, Capacity
The solution doesn´t work.