0

I have a tab delimeted file that I want to convert into a mysql table. there are 25 tab delimeted fields in the text file.
I can get the values in when I construct the SQL statement word by word and get each value individually stated in the VALUES part but when I try to get the list as a whole it does not work. Here is the code. I couldn't figure it out. Any ideas?

for line in lines[1:]:

	linex=line.strip().split("\t")
	linex.insert(0,'sometextindex')       
	
	try:
		cursor.execute('INSERT INTO variants VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',linex) 
	except:
		print 'line number=',a,linex

Edited by biomed: n/a

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by biomed
0

The answer came from stackoverflow site. I used LOAD DATA LOCAL INFILE instead and it solved my problem.

I have a tab delimeted file that I want to convert into a mysql table. there are 25 tab delimeted fields in the text file.
I can get the values in when I construct the SQL statement word by word and get each value individually stated in the VALUES part but when I try to get the list as a whole it does not work. Here is the code. I couldn't figure it out. Any ideas?

for line in lines[1:]:

	linex=line.strip().split("\t")
	linex.insert(0,'sometextindex')       
	
	try:
		cursor.execute('INSERT INTO variants VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',linex) 
	except:
		print 'line number=',a,linex
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.