shlogg · Early preview
Judy @esproc_spl

Error Handling In Text File Processing With EsProc

Text file analysis: handle null fields, empty rows & calculate sales. Script p1.dfx in esProc: loop through sequence, calculate Quantity * Unit Price, output errors or total sales.

Problem description & analysis
Below is text file txt.txt, where the second column contains quantities and the third column contains unit prices:
111111,34,24.5,Apple
222222,53,22.0,Mango
333333,,32.0,Orange
44444,22,12.6,
We are trying to handle this text file according to requirements below:

If there is any null field in the current row, output the words “Error in line# N: insufficient/invalid data”;
If the current row is empty, output the words “Line# N is empty”;
Simple calculations;
Append an empty row and a row of total sales, as shown below:

  
  
  Transactions

Sold 34 Apple at £24....