Support Article
Service File cannot read lines with backslash (\)
SA-21523
Summary
A Service File rule using a Parse Delimiter rule to read a .txt file line by line fails if the text contains a backslash or the defined escape character.
Error Messages
com.pega.pegarules.pub.PRException: Error while parsing: Invalid escape sequence. Escape character must be followed by either field delimiter, or record delimiter, or another escape character.
Steps to Reproduce
- Set up a Service File rule using a Parse Delimiter rule to read a .txt file line by line.
- Use a file listener to implement the Service file rule. Check the box on the Process tab for generating the report file. Use delimiter \n and record terminator \n.
- Put a text file with a line that has a backslash.
- Start the file listener.
Root Cause
The Parse Delimiter code expects the defined escape character to escape a special character such as a field delimiter, record delimiter, or another escape character. This is what the escape sequence should do. The escape sequence followed by a non special character is an error.
Resolution
Perform the following local-change:
Select an escape character (single character sequence) that is unlikely to be in the data sets to be processed. As an example a cent sign might be appropriate.
Published April 1, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.