I have a csv file that I'm intending to import into a mysql
table. I would therefore like to make sure I'm reporting it's LINES TERMINATED BY
properly. However I cannot figure out what characters are terminating the lines in this csv.
I'd guess that it's terminated by \n
(the standard Unix EOL). How can I determine this for sure?
I've tried
cat -v file.csv
file file.csv
I've also tried using vim and :set list
which just showed the location of line breaks with $
Any suggestions would be appreciated
You can create a hex-dump of your file with
xxd
which is part of thevim-common
package.Then check the line endings:
You can use the
file
to give you an indication of the type of line endings.Unix:
DOS:
and knowing that DOS uses carriage return and line feed ("\r\n") as a line ending, which Unix uses just line feed ("\n").
So you can determine what is EOL of any file you want.
Instead of CHECKING, why not simply SET the line ending style you prefer:
sudo apt-get dos2unix
will give you access todos2unix
andunix2dos
command line utilities.These will convert text files according to the names.
Caveat: files with mixed content has been troublesome, I'm not updated on whether that problem is gone.