I have a malformed CSV file with many lines similar to:
a;b;c;d;e;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;^M
I am struggling to find the right regular expression to use in my Vi editor to eliminate the multiple contiguous semicolons (there are many more on each row) and the DOS ^M and obtain just the clean data such as
a;b;c;d;e;
CodePudding user response:
First, you need to remove the trailing semi-colons with
:%s/;\ $//g
Then, run this to convert line breaks to LF:
::set ff=unix
And save the file:
:w