Streaminsets

Expression Language

https://streamsets.com/documentation/datacollector/latest/help/index.html#Expression_Language/ExpressionLanguage_overview.html

index,Machine,Marking,test_1,test_2,v1,v2
1,M1,Y,PASS,Pass,-0.414786145,-2.72791694
2,M1,Y,PASS,PASS,0.914192788,2.275457013
3,M1,Y,ERROR,Error,0.426770455,6.752612253
4,M1,Y,FAIL,Fail,0.847841389,1.470869195
5,M1,Y,ERROR,,-0.133332364,5.025635335
6,M1,Y,ERROR,Error,-0.431192197,8.39033557
7,M1,N,PASS,PASS,0.12986933,2.821072659
8,M1,N,PASS,Error,0.339116242,2.201105834
9,M1,N,FAIL,Fail,-0.796787047,4.7163119
10,M1,N,FAIL,FAIL,0.145608302,6.241871058
11,M2,Y,FAIL,fail,0.094821165,3.072464378
12,M2,Y,ERROR,,0.388589889,2.067567363
......


87,M1,N,PASS,PASS,0.622846062,-7.937454048
88,M1,N,PASS,Error,-0.016543853,1.517224412
89,M1,N,FAIL,Fail,-0.492944884,-7.593005248
90,M1,N,FAIL,FAIL,0.971067023,7.088177071
91,M2,Y,FAIL,fail,-0.679621086,-0.334826948
92,M2,Y,ERROR,,0.060926207,-9.088651796
93,M2,Y,FAIL,Fail,-0.898166328,9.48234628
94,M2,Y,PASS,PASS,0.830169763,3.403456305
95,M2,Y,PASS,PASS,0.76822515,8.312841191
96,M2,Y,PASS,Pass,-0.060944242,4.192534404
97,M2,Y,FAIL,Fail,-0.131796024,4.016210004
98,M2,Y,PASS,Pass,-0.602907755,-9.211080815
99,,,PASS,Pass,-0.93071116,9.102965374
100,,,PASS,PASS,-0.352959669,-9.429255579
  • Required Fields:/test_1
  • Condition
    ${record:value('/test_1')=='PASS'}
    Streaminsets_第1张图片
try: 
  for record in records:
    cc = record.value['credit_card']
    if cc == '':
      error.write(record, "Payment type was CRD, but credit card was null")
      continue
    cc_type = ''
    if cc.startswith('4'):
      cc_type = 'Visa'
    elif cc.startswith(('51','52','53','54','55')):
      cc_type = 'MasterCard'
    elif cc.startswith(('34','37')):
      cc_type = 'AMEX'
    elif cc.startswith(('300','301','302','303','304','305','36','38')):
      cc_type = 'Diners Club'
    elif cc.startswith(('6011','65')):
      cc_type = 'Discover'
    elif cc.startswith(('2131','1800','35')):
      cc_type = 'JCB'
    else:
      cc_type = 'Other'
    record.value['credit_card_type'] = cc_type
    output.write(record)
except Exception as e:
  error.write(record, e.message)

你可能感兴趣的:(Streaminsets)