I'm very new to mysql and I can't find any information about this on the internet... can someone who's an expert please tell me whether you think it's impossible to load a .txt file into a mysql table using similar syntax to this:

LOAD DATA LOCAL INFILE '/path/test2.txt' INTO TABLE test FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\r\n';

This works perfectly for a single-space delimited data file, or if a comma is between the quotes, for a comma-delimited data file. Is there any way at all to tell mysql to look for multiple spaces?

    Do you mean a TAB delimted text file when you say 'multiple spaces'?

    If it is a Tab Delimited text file then use \t :

    LOAD DATA LOCAL INFILE '/path/test2.txt' INTO TABLE test FIELDS TERMINATED BY '\t ' LINES TERMINATED BY '\r\n';

    is the answer.

    If it is just random spaces then I don't know, but I'd be interested in finding out.

      Hehe, yeah. It's definitely not a tab but rather, 'random spaces'. I'll probably reply to my own post if I find out but right now I'm edging towards converting to .csv format as this is the common practice...

        Write a Reply...