0

I have a csv file with four columns. Structure of this file is as shown below.

"Id","Title","Content","Author" "1","......","..............","..." "2",".............","....................","......"

The command below

 LOAD DATA LOCAL INFILE '/data/trn.csv' INTO TABLE TR_DATA FIELDS TERMINATED BY ',' ENCLOSED BY '"' IGNORE 1 LINES ;   

does not parse correctly and puts wrong inputs to fields. How can I parse correctly?

1
  • 2
    Need more information to answer this question. What do you mean my 'puts wrong inputs to fields'. What is the structure of TR_DATA. What is actually inserted into it when you run above query. Commented Sep 25, 2013 at 14:39

1 Answer 1

1

As documented under LOAD DATA INFILE Syntax:

Note

If you have generated the text file on a Windows system, you might have to use LINES TERMINATED BY '\r\n' to read the file properly, because Windows programs typically use two characters as a line terminator. Some programs, such as WordPad, might use \r as a line terminator when writing files. To read such files, use LINES TERMINATED BY '\r'.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.