0

I have the following code to write to a file:

 each_file.write(url+"|*|"+rep_name+'|*|'+b['_source']['dataset']['ID']+'|*|'+ title+ '|*|'+ description+"\n")

Then, I will load this file into MySql using:

cursor.execute ("LOAD DATA LOCAL INFILE '%s' INTO TABLE testseprator FIELDS TERMINATED by '|*|' LINES TERMINATED BY '\n' (link,repo_name,dataset_id,title,description) SET id = NULL" %(file1,))

which file1 refers to my file path. Now, as you can see in the screenshot below:output screenshot

there is lots of new lines in my file, now, when I insert this data into MySql the table is messed up! I have description text into my link column, .... I think, it is because of new lines that I have in description! how can I fix this problem? I used description1=str(description.strip().strip("")), but, this did not help!

Community
  • 1
  • 1
nina_dev
  • 625
  • 2
  • 10
  • 19

0 Answers0