Category: 1 SPL&Code
Conventional operations of esProc SPL on structured text files
Conventional operations of esProc SPL on structured text files Structured text files refer to TXT files separated by tabs or CSV files separated by commas, which can be seen as data tables. Using esProc SPL makes it easy to perform common SQL-like operations on such files. Assuming that the first row of the file is the field title. A B 1 =T(“scores.txt”) 2 =A1.select(CLASS==2) // filter 3 =A1.avg(Chinese) 4 =A1.max(Math) 5 =A1.sum(English) 6 =A1.derive(English+Chinese+Math:total_score) // derive a total_score column 7 =A1.derive(if(Chinese>=90:”A”,Chinese>=80:”B”,Chinese>=60:”C”;”D”):Chinese_evaluation) // evaluate Chinese score 8 =A1.sort(English) 9 =A1.sort(CLASS,-Math) 10 =A1.groups(CLASS;min(English),max(Chinese),avg(Math)) 11 =A1.groups(CLASS;avg(English):avg_En).select(avg_En<85) 12 =A1.top(-3;English) // Top 3 high English







