2
votes

I have a csv file which has many lines of data and many fields, but whenever i have a file which has "9799678467" under "boardingPointContactNo" field it throws an error.

I want to replace "9799678467" with "9799678467". I want to remove the "/". Which processor should I be used to do this?

This is the snippet of my csv data.

serviceProviderName,serviceId,routeId,busType,sourceLocation,sourceLocationId,boardingPointId,boardingPointContactNo    {fields}

"abc travels and Cargo","106123","15476562","A/C Sleeper   (2+1)","Surat","473","21765854","9799678467\"                   {values of each field}

As you can see the data is comma separated.

1

1 Answers

1
votes

You can replace the \ by doing a regex replace where you use \\ as the search pattern and leave the replacement text blank.

However, bear in mind that your export process could be broken and this will leave unescaped double quotes and things like that. CSV is a very ugly format for these reasons, and so you may need to investigate your data a little to see if you have any cases where you need to go deeper and get more creative.

If you find that you do, use ExecuteScript. You can just set a Scanner object on the InputStream from the flowfile and read it line by line, have some Groovy code cleanup for you and the write it back out. Unfortunately, CSV export processes are often crap and you may need this level of control depending on what you find.