This is all that I get when I run it...<br><br>Traceback (most recent call last):<br> File "./loadcsv.py", line 23, in ?<br> co.execute("""<br> File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute<br>
query = query % db.literal(args)<br>TypeError: not all arguments converted during string formatting<br><br><br><div class="gmail_quote">On Fri, Mar 21, 2008 at 1:34 PM, Kent Johnson <<a href="mailto:kent37@tds.net">kent37@tds.net</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">Spencer Parker wrote:<br>
> I posted it in a previous message on the list...but here it is...<br>
<br>
</div>Looks new to me...<br>
<div class="Ih2E3d">><br>
> #!/usr/bin/python<br>
><br>
> import MySQLdb<br>
> import csv<br>
> import sys<br>
><br>
> try:<br>
> db = MySQLdb.connect (host = "localhost",user = "root",passwd =<br>
> "Ch33s3Monk3y",db = "xenstats")<br>
> except MySQLdb.Error, e:<br>
> print "Error %d: %s" % (e.args[0], e.args[1])<br>
> sys.exit (1)<br>
><br>
> try:<br>
> co = db.cursor()<br>
> csv_data = csv.reader(file('output.txt','r'))<br>
> headers = csv_data.next()<br>
> row = csv_data.next()<br>
> prefix = row[:20]<br>
> for i in range(20, len(row), 7):<br>
> next = prefix + row[i:i+7]<br>
><br>
> for row in csv_data: print next<br>
<br>
</div>Why do you have this loop? You only want to process one row, right?<br>
<div class="Ih2E3d"><br>
> co.execute("""<br>
> INSERT INTO stats VALUES<br>
> (%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);<br>
> """,row)<br>
<br>
</div>Should be next - the processed data - not row - the raw data.<br>
<br>
You still didn't show the actual error message. After the traceback<br>
there should be an error.<br>
<font color="#888888"><br>
Kent<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Spencer Parker<br>_______________________________________________________<br><br>"if you can't go to heaven, may you at least die in Ireland."<br><br>
_______________________________________________________