Re: [Tutor] CSV file processing...

2008-03-24 Thread Spencer Parker
I took out the quotes around the second part of the INSERT statement and that made it work fine. On Mon, Mar 24, 2008 at 10:49 AM, Spencer Parker <[EMAIL PROTECTED]> wrote: > Okay...so I don't know what I was missing...but I copied the code from a > file I had without the loop in it...now it work

Re: [Tutor] CSV file processing...

2008-03-24 Thread Spencer Parker
Okay...so I don't know what I was missing...but I copied the code from a file I had without the loop in it...now it works just fine...I'm going through to see what changed right now...thanks for the help...it is appreciated... On Mon, Mar 24, 2008 at 10:30 AM, Kent Johnson <[EMAIL PROTECTED]> wrot

Re: [Tutor] CSV file processing...

2008-03-24 Thread Kent Johnson
Spencer Parker wrote: > I am pretty sure it is trying to tell me that the data I have is not > matching up with the columns I have in mysql. Yes, I think so. > > The output I get from the print next is this: > > ['test.test.net ', '15:33:59', 'x86_64', '8', '9', > '1', '4

Re: [Tutor] CSV file processing...

2008-03-24 Thread Spencer Parker
I am pretty sure it is trying to tell me that the data I have is not matching up with the columns I have in mysql. The output I get from the print next is this: ['test.test.net', '15:33:59', 'x86_64', '8', '9', '1', '4', '0', '0', '0', '0', '5', '4', '0.0', '12495360', '818688', '0', '36', 'core.

Re: [Tutor] CSV file processing...

2008-03-24 Thread Kent Johnson
Spencer Parker wrote: > Okay...that got me a different error: > _mysql_exceptions.OperationalError: (1136, "Column count doesn't match > value count at row 1") So, what do you think that error might be trying to tell you? What output do you get from the 'print next' statement? Kent __

Re: [Tutor] CSV file processing...

2008-03-24 Thread Spencer Parker
Okay...that got me a different error: Traceback (most recent call last): File "./loadcsv.py", line 21, in ? co.execute(""" File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 163, in execute self.errorhandler(self, exc, value) File "/usr/lib64/python2.4/site-packages/M

Re: [Tutor] CSV file processing...

2008-03-24 Thread Kent Johnson
Spencer Parker wrote: > I am at a loss as to why this isn't working properly: > > #!/usr/bin/python > > import MySQLdb > import csv > import sys > > try: > db = MySQLdb.connect (host = "localhost",user = "root",passwd = > "",db = "stats") > except MySQLdb.Error, e: > print "Erro

Re: [Tutor] CSV file processing...

2008-03-24 Thread Spencer Parker
I am at a loss as to why this isn't working properly: #!/usr/bin/python import MySQLdb import csv import sys try: db = MySQLdb.connect (host = "localhost",user = "root",passwd = "",db = "stats") except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit (

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Marc Tompkins wrote: > Sorry... no, it still shouldn't work... > maybe like so: > co.execute('''INSERT INTO stats > 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" > > % row''') > > > You have triple quotes around your SQL. That means that "implied" >

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > Okay...so this is what I have now.. Do you really expect us to read through this? If you can't be bothered to compose a decent question and read the answers then neither can I. Kent ___ Tutor maillist - Tutor@python.org http:/

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
Okay...so this is what I have now.. co.execute(""" File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute query = query % db.literal(args) TypeError: not enough arguments for format string [EMAIL PROTECTED] ~]$ vim loadcsv.py [EMAIL PROTECTED] ~]$ vim output.t

Re: [Tutor] CSV file processing...

2008-03-21 Thread Marc Tompkins
Sorry... no, it still shouldn't work... maybe like so: co.execute('''INSERT INTO stats 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" % row''') > You have triple quotes around your SQL. That means that "implied" line > breaks become real. It won't look as ni

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > That loop was some weird indentation that was caused when I pasted > it...it wasn't suppose to be indented like that... Why is it there at all? The loop with range() is the one that is generating the data you want to store. > This is all that I get when I run it... >

Re: [Tutor] CSV file processing...

2008-03-21 Thread Marc Tompkins
On Fri, Mar 21, 2008 at 12:42 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > This is all that I get when I run it... > > Traceback (most recent call last): > File "./loadcsv.py", line 23, in ? > co.execute(""" > File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, > in

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
I took that loop out...I had that in from something else and forgot to take it out...I took it out and it still does the same error. On Fri, Mar 21, 2008 at 1:44 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > That loop was some weird indentation that was caused when I pasted it...it > wasn't sup

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
That loop was some weird indentation that was caused when I pasted it...it wasn't suppose to be indented like that... On Fri, Mar 21, 2008 at 1:42 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > This is all that I get when I run it... > > Traceback (most recent call last): > File "./loadcsv.py"

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
This is all that I get when I run it... Traceback (most recent call last): File "./loadcsv.py", line 23, in ? co.execute(""" File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute query = query % db.literal(args) TypeError: not all arguments converted during

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > I posted it in a previous message on the list...but here it is... Looks new to me... > > #!/usr/bin/python > > import MySQLdb > import csv > import sys > > try: > db = MySQLdb.connect (host = "localhost",user = "root",passwd = > "Ch33s3Monk3y",db = "xenstats") > exc

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
I posted it in a previous message on the list...but here it is... #!/usr/bin/python import MySQLdb import csv import sys try: db = MySQLdb.connect (host = "localhost",user = "root",passwd = "Ch33s3Monk3y",db = "xenstats") except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > Okay...so I got it mostly working...it now dies with this trackback: It would be helpful to see what 'it' is (i.e. your code), and also to see the actual error message as well as the traceback. We try to read minds on this group but we aren't really very good at it. Kent

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
Okay...so I got it mostly working...it now dies with this trackback: Traceback (most recent call last): File "./loadcsv.py", line 23, in ? co.execute(""" File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute query = query % db.literal(args) On Fri, Mar 21,

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > So if my long row is row two...how do I tell it to use row 2? csv_data = csv.reader(file('output.txt','r')) headers = csv_data.next() # Skip header row row = csv_data.next() # The row with data Kent ___ Tutor maillist - Tutor@p

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
So if my long row is row two...how do I tell it to use row 2? On Thu, Mar 20, 2008 at 5:42 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Spencer Parker wrote: > > I am trying to read a CSV file and the get that information into a MySQL > > database. I am able to do this, but I have a small probl

Re: [Tutor] CSV file processing...

2008-03-21 Thread Eric Walstad
Hey Spencer, Spencer Parker wrote: > This is why I should not be allowed to write emails at the end of the > day. At least ones that need deep explanation. Let's try this a second > time. Thanks, this looks better, but... > This is what I have now... *What isn't working* the way you want? T

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
This is why I should not be allowed to write emails at the end of the day. At least ones that need deep explanation. Let's try this a second time. I am running virt-top on a Xen box. This grabs information about various things. I can set how many iterations of it I want to run. I only have it

Re: [Tutor] CSV file processing...

2008-03-20 Thread bob gailer
On Thu, Mar 20, 2008 at 03:16:05PM -0600, Spencer Parker wrote: I've interspersed a bunch of comments to show you how hard it has been to read and understand your problem description. After going thru it I think I understand the question. Please in the future try to express the question more

Re: [Tutor] CSV file processing...

2008-03-20 Thread Dave Kuhlman
On Thu, Mar 20, 2008 at 03:16:05PM -0600, Spencer Parker wrote: > I am trying to read a CSV file and the get that information into a MySQL > database. I am able to do this, but I have a small problem. I have a piece > of software that runs and each iteration is one like. It only runs once > righ

Re: [Tutor] CSV file processing...

2008-03-20 Thread Eric Walstad
Hi Spencer Spencer Parker wrote: > I have a > piece of software that runs and each iteration is one like. I don't understand what this means. > It only > runs once right now; there is only one line + the headers. I use the > csv module to kill the headers and import the one line. Does 'kill

Re: [Tutor] CSV file processing...

2008-03-20 Thread Kent Johnson
Spencer Parker wrote: > I am trying to read a CSV file and the get that information into a MySQL > database. I am able to do this, but I have a small problem. I have a > piece of software that runs and each iteration is one like. It only > runs once right now; there is only one line + the hea

[Tutor] CSV file processing...

2008-03-20 Thread Spencer Parker
I am trying to read a CSV file and the get that information into a MySQL database. I am able to do this, but I have a small problem. I have a piece of software that runs and each iteration is one like. It only runs once right now; there is only one line + the headers. I use the csv module to ki