AnirD
AnirD

Reputation: 49

Removing Carriage Return (Control-M) in Groovy

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 .

Upvotes: 0

Views: 229

Answers (2)

Gicu Aftene
Gicu Aftene

Reputation: 532

Something like this should work....

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

Upvotes: 0

user11844224
user11844224

Reputation:

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.

Upvotes: 1

Related Questions