Question

1
Replies
1255
Views
RaviK518 Member since 2016 40 posts
MSoft
Posted: 3 years ago
Last activity: 3 years 6 months ago
Closed

Java Custom Activity to Parse the Excel file and save it to Data-table .

have the following CSV file

The below format File will be uploaded from the User Interface and clicks on Submit Button .

Name,FirstName,Password
Terry,Adams,01091990
Ann,Beebe,02111991
Chris,Cannon,03281986

Steps i followed to parse the csv file and save it to DataTable

Step 1:

Created a DataTable with following 3 properties .
Name,FirstName,Password

Step 2 :

Caling the below Activicty (RecInsert_Activicty) with java code .

After Setting the values How can i tell the Activicty to save the Data to DataTable .

Please let me know if this is the right approach to insert the Data through Activity when File uploaded through User Interface .

try
{
ClipboardPage objRequestorPage = tools.getRequestor().getRequestorPage();
String strFile = objRequestorPage.getString("pyFileUpload");
com.pega.pegarules.pub.util.PRFile objFile = new PRFile(strFile);

  java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.StringReader(objFile));
				String line = null;
				int i = 0;
				while ((line = br.readLine()) != null) {
					String splitstr[] = line.split(",");
					String name = splitstr[0];
					String firstName = splitstr[1];
					String password = splitstr[2];

					tools.getStepPage().getProperty("Name").setValue("name");
					tools.getStepPage().getProperty("FirstName").setValue("firstName");
					tools.getStepPage().getProperty("Password").setValue("Password");

} // try ends here 
catch(Exception e)
{
e.printStackTrace();
}
Data Integration Java and Activities
Moderation Team has archived post
Share this page LinkedIn