Need assistance with syntax errors python scripts : tester: lineCust ReduceJoin .py #!/usr/bin/pytho
Need assistance with syntax errors python scripts:
tester:
lineCustReduceJoin.py
#!/usr/bin/python
import sys
currentKey = None
quantity = []
revenue = []
nation = ''
# input comes from STDIN
for line in sys.stdin:
split = line.strip().split('t')
key = split[0] # key is customer id
value = 't'.join(split[1:])
if currentKey == key: # Same key
if value.endswith('lineorder'):
quantity.extend([split[1]])
revenue.extend([split[2]])
if value.endswith('customer'):
nation = split[1]
else:
# Do not print anything until all records
# for a key have been seen, this is signaled
# by currentKey != key
# Check for values and then iterate results
lenQuantity = len(quantity)
lenNation = len(nation)
if (lenQuantity*lenNation > 0):
i = 0
while i
print quantity[i], 't', nation, 't', revenue[i]
i += 1
# reset values
quantity = []
revenue = []
nation = ''
if value.endswith('lineorder'):
quantity.extend([split[1]])
revenue.extend([split[2]])
if value.endswith('customer'):
nation = split[1]
# set the current key at the end of each iteration
currentKey = key
dataset customer.tbl={1|Customer#000000001|j5JsirBM9P|MOROCCO 0|MOROCCO|AFRICA|25-989-741-2988|BUILDING|
2|Customer#000000002|487LW1dovn6Q4dMVym|JORDAN 1|JORDAN|MIDDLE EAST|23-768-687-3665|AUTOMOBILE|
3|Customer#000000003|fkRGN8n|ARGENTINA7|ARGENTINA|AMERICA|11-719-748-3364|AUTOMOBILE| }
dataset lineorder = {1|1|7381|155190|828|19960102|5-LOW|0|17|2116823|17366547|4|2032150|74711|2|19960212|TRUCK|
1|2|7381|67310|163|19960102|5-LOW|0|36|4598316|17366547|9|4184467|76638|6|19960228|MAIL|
1|3|7381|63700|71|19960102|5-LOW|0|8|1330960|17366547|10|1197864|99822|2|19960305|REG AIR|}