Home > Software engineering >  Removing Carriage Return (Control-M) in Groovy
Removing Carriage Return (Control-M) in Groovy

Time:11-28

My file is having unwanted Control-M characters at the end of the records and because of this file is not getting processed.

Sample file (CSV) Sample file

Please suggest how can I use ReplaceAll function in Groovy to remove it .

CodePudding user response:

This depends on your shell/OS; try "^M" (in the ReplaceAll function), but this is entered by first pressing the "v" key while holding the "control" key down, then pressing the "return" key.

CodePudding user response:

Something like this should work....

csvFileContent.replaceAll("\r\n", "\n");
  • Related