Group & Summarize a CSV File
Problem description & analysis
Below is CSV file sample.csv:
We are trying to group the file by City and calculate average of Income. Below is the desired result:
Bangalore - 48766
Delhi - 44444
Hyderabad - 54322
Mumbai - 43211
Write the script p1.dfx below in esProc:
=A1.groups(City;int(avg(Income))).(#1/" - "/#2)
A1 Import the CSV file containing table headers.
A2 Group A1 by City and calculate average of Income, and output the grouped table sequence according to the desired format.
Read How to Call an SPL Script in Java to learn how to integrate the script code into a Java program.