I would like to add ^M at the end of all row in CSV file

224 views Asked by At

I have the CSV file that contains data around 100M rows and I would like to add ^M at the end of each row because if not have a ^M I cannot load the CSV file into the table(It just load only the 1st row and then ignore another row).

I tried to add ^M with go to the end of row and press Ctrl+V and Ctrl+M and test load again then it works, but I cannot manual input ^M every row and I cannot generate the new CSV file again because it takes a very long time.

The example original a,b,c,d aa,bb,cc,dd

My expect a,b,c,d^M aa,bb,cc,dd^M


I tried to use :%s/$/^M/g and ex +"%s/$/^M/g" -cwq ITEM_1.csv

but it is like I use a enter command like this

The example original a,b,c,d aa,bb,cc,dd

After command, it have a blank new line, not ^M a,b,c,d

aa,bb,cc,dd

Thank and Best Regards,

1

There are 1 answers

6
Artagel On BEST ANSWER

Why not just use unix2dos? You essentially want to do the reverse of dos2unix

http://www.linuxcommand.org/man_pages/unix2dos1.html