(CSV) Trim excess commas

This special process is used to remove excess commas from a CSV file. Those commas after the last piece of valid data will be removed.

For example the file before applying this process looks like:

 

Data1,Data2,Data3,Data4,,,

,, ,

Data1,Data2,Data3,Data4,,,

Data1,Data2,Data3,Data4

 

After applying this process it looks like:

 

Data1,Data2,Data3,Data4

,,

Data1,Data2,Data3,Data4

Data1,Data2,Data3,Data4

Data1,Data2,Data3,Data4

 

Notice the space character, though not visible/shown in row 2, column 2, is valid data.