0

Basically i'm going to take an exam in mysql next week in which i will have to import some txt files in my editor and launch some query on it. My problem is that my professor randomly changes '\n' with '\r\n' and i don't know how can i notice it before importing. Is there any way to do it in a minimal windows 7 machine with only Mysql query browser as editor and windows notepad?

Thanks!

i tried by importing it both in query browser, both in notepad.

Raydar
  • 5
  • 2

1 Answers1

0

I have a file /tmp/win.txt in which I saved:

Hello\r\n
World\r\n

Then I used MySQL to load the file and check if it contains \r\n characters:

mysql> select instr(load_file('/tmp/win.txt'), '\r\n');
+------------------------------------------+
| instr(load_file('/tmp/win.txt'), '\r\n') |
+------------------------------------------+
|                                        6 |
+------------------------------------------+

Note this depends on having your MySQL configured with the option secure_file_priv=/tmp, or else you can't use LOAD_FILE().

But if I were working on this task, I would just make sure the text file was in UNIX format, so I don't have to test every file with MySQL. See Windows command to convert Unix line endings?

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828