What does ^M character mean and how do you import a csv into mysql with it?

This comes up for me from time to time and I always forget how to deal with it.

Basics, the ^M is a carriage return or newline symbol, but probably not one produced in your OS. You’ll want to switch it to your system’s default newline so it recognizes it.

Here’s how you might do that in vi/vim

%s/\r/\r/g

It’s doing a replace with the carriage return /r with the system’s default carriage return /r.

Don’t question it, just do it!
But back up the original file just in case I’m wrong :/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: