0

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,

OldProgrammer
  • 10,029
  • 3
  • 24
  • 39
user7333846
  • 79
  • 3
  • 9

1 Answers1

4

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

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

Artagel
  • 392
  • 1
  • 12
  • Wow Thank you so much. Previously, I understand that the unix2dos only use to remove the ^M only but I just tried to use the unix2dos from your recommend and its work – user7333846 Dec 29 '16 at 20:01
  • but I cannot modify the large CSV file. It showed error "Value too large for defined data type." – user7333846 Dec 29 '16 at 20:13
  • Is your OS 32 bit? If so, you are running into a problem with the size of your data not being able to be handled in 32-bit. Try it on a 64-bit OS. – Artagel Dec 30 '16 at 04:14
  • that is a: isainfo -v 64-bit sparcv9 applications crc32c cbcond pause mont mpmul sha512 sha256 sha1 md5 camellia kasumi des aes ima hpc vis3 fmaf asi_blk_init vis2 vis popc 32-bit sparc applications crc32c cbcond pause mont mpmul sha512 sha256 sha1 md5 camellia kasumi des aes ima hpc vis3 fmaf asi_blk_init vis2 vis popc v8plus div32 mul32 – user7333846 Dec 30 '16 at 04:49
  • Oh, this is solaris :) There's going to be all kinds of fun caveats. – Artagel Dec 30 '16 at 06:42
  • This is likely your reason: https://docs.oracle.com/cd/E19455-01/806-1075/msgs-2215/index.html – Artagel Dec 30 '16 at 06:43