Compile Cheetah Template on Windows

2007-11-24 Thread brianrpsgt1
Newbie here

I have been able to successful pull info from a MySQL DB, get the
results and output them in an HTML format using Cheetah to the screen
using IDLE.  I am doing this on a Windows Laptop, running WinXP,
Python 2.5 and the latest version of Cheetah.

I have two questions:
1. How and where do you compile Cheetah templates in Windows?  The
command in the docs is cheetah compile a, however, I believe that this
is for Linux.  This does nothing in a DOS Prompt.  Please provide the
info for this command in Windows.

2. How do I output the HTML to a file?  I tried the following:

FILE = open(filename, "wt")
FILE.writelines(output)
FILE.close()

I get an error though that states that writelines() requires an
interable argument

Thnx for any assistance!

B

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compile Cheetah Template on Windows

2007-11-28 Thread brianrpsgt1
Tim, thank you very much for the reply.  The 'cheetah' function is now
working!

I am still having a problem creating the file.  I continually get
errors.  I am sure that it is something very simple.

Below is the code, please guide me in the right direction ::

import psycopg2, psycopg2.extensions
from Cheetah.Template import Template
import operator
import os
from SafetyNet import SafetyNet

filename = open("C:\Python25\Lib\site-packages\PSN
\InstalledDevices.html")

db = psycopg2.connect("dbname='XXX' user='XXX' host='XXX'")

pocmonitors_cur = db.cursor()
pocmonitors_cur.execute("""SELECT pocmonitor_name, pocmonitor_sn FROM
pocmonitor ORDER BY pocmonitor_name""")

pocmonitors = []

for i in range(pocmonitors_cur.rowcount) :
pocmonitors.append(pocmonitors_cur.fetchone())
pocmonitors_cur.close()
db.close()

total_results = len(pocmonitors)

nameSpace = {'title': 'First Cheetah Example', 'pocmonitors':
pocmonitors, 'total_results': total_results}

output = Template(file='C:\Python25\Lib\site-packages\PSN
\SafetyNet.tmpl', searchList=[nameSpace])

print output


filename.write(output)



Thanks for the help!

B



Tim Roberts wrote:
> brianrpsgt1 <[EMAIL PROTECTED]> wrote:
> >
> >I have been able to successful pull info from a MySQL DB, get the
> >results and output them in an HTML format using Cheetah to the screen
> >using IDLE.  I am doing this on a Windows Laptop, running WinXP,
> >Python 2.5 and the latest version of Cheetah.
> >
> >I have two questions:
> >1. How and where do you compile Cheetah templates in Windows?  The
> >command in the docs is cheetah compile a, however, I believe that this
> >is for Linux.  This does nothing in a DOS Prompt.  Please provide the
> >info for this command in Windows.
>
> The Cheetah installation should have created scripts called "cheetah" and
> "cheetah-compile" in your Python25\Scripts directory.  The issue you have
> is that they aren't on your path.
>
> One answer is to copy Python25\Scripts\cheetah to \Windows\cheetah.py and
> Python25\Scripts\cheetah-compile to \Windows\cheetah-compile.py.  Then you
> can type "cheetah.py compile xxx" or "cheetah-compile.py xxx".
>
> However, you don't have to compile them in advance.  You can do "from
> Cheetah.Template import Template" and compile them on the fly, with
>tmpl = Template( file='page.tmpl' )
>
> >2. How do I output the HTML to a file?  I tried the following:
> >
> >FILE = open(filename, "wt")
> >FILE.writelines(output)
> >FILE.close()
> >
> >I get an error though that states that writelines() requires an
> >interable argument
>
> Just use FILE.write( output ).
> --
> Tim Roberts, [EMAIL PROTECTED]
> Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


pythonweb and Leopard

2008-03-24 Thread brianrpsgt1
I am trying to create a simple web application that is written in
python, using apache and mysql.  It appears as though the python web
modules have been installed, however, whenever I try to run a python
script, it only displays the code in the browser.  It is like the
python code is not getting processed.  I have tried this on a iMac
(Intel) and a PowerBook G4, both running Leopard.

Python Web Modules 0.5.3
Apache 2.2
Python 2.5

I am trying to run the python script from the default web directory on
the Mac, /Library/WebServer/Documents
I updated the httpd.conf for the  to say Options +ExecCGI
and AddHandler cgi-script .cgi .py

I know that I am missing something simple.

Any help would be great

B
-- 
http://mail.python.org/mailman/listinfo/python-list


Break large file down into multiple files

2009-02-12 Thread brianrpsgt1
New to python I have a large file that I need to break up into
multiple smaller files. I need to break the large file into sections
where there are 65535 lines and then write those sections to seperate
files.  I am familiar with opening and writing files, however, I am
struggling with creating the sections and writing the different
sections to their own files.

Thanks

B
--
http://mail.python.org/mailman/listinfo/python-list


Re: Break large file down into multiple files

2009-02-12 Thread brianrpsgt1
On Feb 12, 11:02 pm, "Gabriel Genellina" 
wrote:
> En Fri, 13 Feb 2009 04:44:54 -0200, brianrpsgt1   
> escribió:
>
> > New to python I have a large file that I need to break upinto
> > multiple smallerfiles. I need to break the large fileintosections
> > where there are 65535 lines and then write thosesectionsto seperate
> >files.  I am familiar with opening and writingfiles, however, I am
> > struggling with creating thesectionsand writing the different
> >sectionsto their ownfiles.
>
> This function copies at most n lines from fin to fout:
>
> def copylines(fin, fout, n):
>    for i, line in enumerate(fin):
>      fout.write(line)
>      if i+1>=n: break
>
> Now you have to open the source file, create newfilesas needed and  
> repeatedly call the above function until the end of source file. You'll  
> have to enhace it bit, to know whether there are remaining lines or not.
>
> --
> Gabriel Genellina

Gabriel ::

Thanks for the direction.  Do I simply define fin, fout and n as
variables above the def copylines(fin, fout, n): line?

Would it look like this?

fin = open('C:\Path\file')
fout = 'C:\newfile.csv')
n = 65535

def copylines(fin, fout, n):
for i, line in enumerate(fin):
      fout.write(line)
      if i+1>=n: break

Thanks

B
--
http://mail.python.org/mailman/listinfo/python-list


count secton of data in list

2009-02-20 Thread brianrpsgt1
I have a list of three columns of data.  I run the following code:

def step1(val):
for d1r in data1_row:
if d1r[1] >= val:
switch = 0
data2_row = d1r[0],d1r[1],d1r[2],switch
print d1r[0],d1r[1],d1r[2],switch
else:
switch = 1
print d1r[0],d1r[1],d1r[2],switch

step1(95)

After running that code I get four columns with either a '0' or '1' in
the 4th column, as shown below

2009-01-09 13:17:30 96 123456 0
2009-01-09 13:17:31 95 123456 0
2009-01-09 13:17:32 95 123456 0
2009-01-09 13:17:33 95 123456 0
2009-01-09 13:17:34 94 123456 1
2009-01-09 13:17:35 94 123456 1
2009-01-09 13:17:36 94 123456 1
2009-01-09 13:17:37 94 123456 1
2009-01-09 13:17:38 94 123456 1
2009-01-09 13:17:39 94 123456 1
2009-01-09 13:17:40 94 123456 1
2009-01-09 13:17:41 94 123456 1
2009-01-09 13:17:42 95 123456 0
2009-01-09 13:17:43 95 123456 0
2009-01-09 13:17:44 95 123456 0
2009-01-09 13:17:45 95 123456 0

Where I am getting stuck is that I now need to get the individual
counts for the various consecutive areas in the list where the values
are '1'.  I was trying to run a FOR Loop on the variable data2_row
but that does not work.  Any assistance would be great.

Thanks:
B

--
http://mail.python.org/mailman/listinfo/python-list


Read data from Serial Command

2008-10-10 Thread brianrpsgt1
I am new to scripting.  I am trying to read the settings from a serial
device using Python.  I have been able to successfully connect to the
device and change baud rate settings, ect... with PySerial.  I am
trying to send a command to the serial device and capture the returned
info, however, it is not working.  Code is below:

import serial
import time

s = serial.Serial(port=1, timeout=None, baudrate=9600)
print s
time.sleep(5)
print "Enter CFG"
s.write('CFG')
print "Change baud"
s.baudrate=115200
print s
time.sleep(5)
print "New line"
s.write('\n')


time.sleep(2)
print "Show Encryption Setting"
nw = s.write('sh nw enc')

time.sleep(1)

print nw
s.close()

Thanks

B
--
http://mail.python.org/mailman/listinfo/python-list


Re: Read data from Serial Command

2008-10-10 Thread brianrpsgt1
Thanks for the message

What exactly is happening is that the return is "None" for the command
that I am sending.  If I connect through Hyperterminal and execute the
'sh nw enc' command, it returns 'WEP'

I have confirmed that the serial port is correct and open with the
s.isOpen() function.  Also able to successfully connect in
Hypterterminal with the same configuration settings.




Grant Edwards wrote:
> On 2008-10-10, brianrpsgt1 <[EMAIL PROTECTED]> wrote:
> > I am new to scripting.  I am trying to read the settings from a serial
> > device using Python.  I have been able to successfully connect to the
> > device and change baud rate settings, ect... with PySerial.  I am
> > trying to send a command to the serial device and capture the returned
> > info, however, it is not working.
>
> It works fine for me.
>
> I'm afraid you're going to have to be a bit more detailed than
> "it is not working".  Are we supposed to guess what it's doing
> and how that differs from what you want it to do?
>
> Do you have the serial cable plugged in?
>
> Is the device to which you're talking powered on?
>
> > Code is below:
> >
> > import serial
> > import time
> >
> > s = serial.Serial(port=1, timeout=None, baudrate=9600)
> > print s
> > time.sleep(5)
> > print "Enter CFG"
> > s.write('CFG')
> > print "Change baud"
> > s.baudrate=115200
> > print s
> > time.sleep(5)
> > print "New line"
> > s.write('\n')
> >
> >
> > time.sleep(2)
> > print "Show Encryption Setting"
> > nw = s.write('sh nw enc')
> >
> > time.sleep(1)
> >
> > print nw
> > s.close()
>
> --
> Grant Edwards   grante Yow! Well, I'm INVISIBLE
>   at   AGAIN ... I might as well
>visi.compay a visit to the LADIES
>ROOM ...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Read data from Serial Command

2008-10-10 Thread brianrpsgt1
Gave that a shot  what is happening is that the script is
hanging.  Does that mean that the write function is not making it
through, thus there is nothing to return?



Grant Edwards wrote:
> On 2008-10-10, brianrpsgt1 <[EMAIL PROTECTED]> wrote:
> > Thanks for the message
> >
> > What exactly is happening is that the return is "None" for the command
> > that I am sending.  If I connect through Hyperterminal and execute the
> > 'sh nw enc' command, it returns 'WEP'
>
> It looks to me like you're never reading from the serial port.
> All you're calling is write().
>
> Also, are you sure that the device doesn't expect commands to
> be termined by carriage returns?
>
> >> > import serial
> >> > import time
> >> >
> >> > s = serial.Serial(port=1, timeout=None, baudrate=9600)
> >> > print s
> >> > time.sleep(5)
> >> > print "Enter CFG"
> >> > s.write('CFG')
> >> > print "Change baud"
> >> > s.baudrate=115200
> >> > print s
> >> > time.sleep(5)
> >> > print "New line"
> >> > s.write('\n')
> >> >
> >> >
> >> > time.sleep(2)
> >> > print "Show Encryption Setting"
> >> > nw = s.write('sh nw enc')
> >> > time.sleep(1)
>
> Try changing that to
>
>  s.write('sh nw enc')
>  time.sleep(1)
>  nw = s.read(1024)
>
> >> > print nw
> >> > s.close()
>
> There are plenty of example programs at:
>
> http://pyserial.svn.sourceforge.net/viewvc/pyserial/trunk/pyserial/examples/
>
> --
> Grant Edwards   grante Yow!
>   at   
> BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-
>visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Read data from Serial Command

2008-10-10 Thread brianrpsgt1
Again, what is weird is that all works fine in Hyperterminal, but not
with the Python script.



brianrpsgt1 wrote:
> Gave that a shot  what is happening is that the script is
> hanging.  Does that mean that the write function is not making it
> through, thus there is nothing to return?
>
>
>
> Grant Edwards wrote:
> > On 2008-10-10, brianrpsgt1 <[EMAIL PROTECTED]> wrote:
> > > Thanks for the message
> > >
> > > What exactly is happening is that the return is "None" for the command
> > > that I am sending.  If I connect through Hyperterminal and execute the
> > > 'sh nw enc' command, it returns 'WEP'
> >
> > It looks to me like you're never reading from the serial port.
> > All you're calling is write().
> >
> > Also, are you sure that the device doesn't expect commands to
> > be termined by carriage returns?
> >
> > >> > import serial
> > >> > import time
> > >> >
> > >> > s = serial.Serial(port=1, timeout=None, baudrate=9600)
> > >> > print s
> > >> > time.sleep(5)
> > >> > print "Enter CFG"
> > >> > s.write('CFG')
> > >> > print "Change baud"
> > >> > s.baudrate=115200
> > >> > print s
> > >> > time.sleep(5)
> > >> > print "New line"
> > >> > s.write('\n')
> > >> >
> > >> >
> > >> > time.sleep(2)
> > >> > print "Show Encryption Setting"
> > >> > nw = s.write('sh nw enc')
> > >> > time.sleep(1)
> >
> > Try changing that to
> >
> >  s.write('sh nw enc')
> >  time.sleep(1)
> >  nw = s.read(1024)
> >
> > >> > print nw
> > >> > s.close()
> >
> > There are plenty of example programs at:
> >
> > http://pyserial.svn.sourceforge.net/viewvc/pyserial/trunk/pyserial/examples/
> >
> > --
> > Grant Edwards   grante Yow!
> >   at   
> > BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-
> >visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Read data from Serial Command

2008-10-10 Thread brianrpsgt1
That did it!  The fix was the '\r'

Thanks for the assistance Dennis and Grant!

Dennis Lee Bieber wrote:
> On Fri, 10 Oct 2008 15:40:08 -0700 (PDT), brianrpsgt1
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
> > Again, what is weird is that all works fine in Hyperterminal, but not
> > with the Python script.
> >
>   And are you hitting the return key when using Hyperterminal?
>
> > > >
> > > > Try changing that to
> > > >
> > > >  s.write('sh nw enc')
>
>   s.write("sh nw enc\r")  #presuming you have to hit the return key in
> Hyperterminal
>
>   You may also want to configure the serial port with a read timeout
> --
>   WulfraedDennis Lee Bieber   KD6MOG
>   [EMAIL PROTECTED]   [EMAIL PROTECTED]
>   HTTP://wlfraed.home.netcom.com/
>   (Bestiaria Support Staff:   [EMAIL PROTECTED])
>   HTTP://www.bestiaria.com/
--
http://mail.python.org/mailman/listinfo/python-list


IDLE stopped working

2008-10-26 Thread brianrpsgt1
Using OS X 10.5.5
Python 2.5.1

IDLE was working, then all of a sudden, the window size went off of
the screen could not resize it.  I closed IDLE and rebooted and
now IDLE will not start.  Below is the Traceback

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/
IDLE", line 5, in 
main()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/PyShell.py", line 1402, in main
shell = flist.open_shell()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/PyShell.py", line 275, in open_shell
self.pyshell = PyShell(self)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/PyShell.py", line 811, in __init__
OutputWindow.__init__(self, flist, None, None)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/OutputWindow.py", line 16, in __init__
EditorWindow.__init__(self, *args)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/EditorWindow.py", line 121, in __init__
height=idleConf.GetOption('main','EditorWindow','height') )
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/MultiCall.py", line 299, in __init__
apply(widget.__init__, (self,)+args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/lib-tk/Tkinter.py", line 2828, in __init__
Widget.__init__(self, master, 'text', cnf, kw)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/lib-tk/Tkinter.py", line 1930, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: bad screen distance "60gill"

Any assistance in getting this back up and running would be great

Thanks

B
--
http://mail.python.org/mailman/listinfo/python-list


IDLE stopped working

2008-10-26 Thread brianrpsgt1
OSX 10.5.5
Python 2.5.1

I started up IDLE today and the bottom of the window was off of the
screen.  I could not find a way to resize it.  I closed all apps and
rebooted.  After rebooting, IDLE will not start.  Below is the
Traceback:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/
IDLE", line 5, in 
main()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/PyShell.py", line 1402, in main
shell = flist.open_shell()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/PyShell.py", line 275, in open_shell
self.pyshell = PyShell(self)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/PyShell.py", line 811, in __init__
OutputWindow.__init__(self, flist, None, None)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/OutputWindow.py", line 16, in __init__
EditorWindow.__init__(self, *args)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/EditorWindow.py", line 121, in __init__
height=idleConf.GetOption('main','EditorWindow','height') )
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/idlelib/MultiCall.py", line 299, in __init__
apply(widget.__init__, (self,)+args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/lib-tk/Tkinter.py", line 2828, in __init__
Widget.__init__(self, master, 'text', cnf, kw)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/lib-tk/Tkinter.py", line 1930, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: bad screen distance "60gill"

Thanks for any assistance


B
--
http://mail.python.org/mailman/listinfo/python-list


Insert data into MySQL from HTML Form using .psp script

2008-11-08 Thread brianrpsgt1
I am attempting to insert data from a HTML form using a .psp script.
I can not find how to link the data that is inserted into the form to
the variables in the .psp script to then insert into the MySQL Insert
statement.  I am familiar with PHP, where you would write
$_POST(['field']), however I can not find the equivalent in PSP.  I
believe that this is the my missing piece.  Technically, what is
occurring that that when I click the 'Submit' button, it is inserting
NULL field values into the db.

Sample code is below ::

HTML FORM CODE






PAGE

Date:


Time:


Activity:


Next Steps:






Below is the psp script

<%
import MySQLdb

host = 'localhost'
user = 'user'
passwd = 'somepass'
db = 'MyDB'

conn = MySQLdb.connect(host, user, passwd, db)
mysql = conn.cursor()

sql = ("""INSERT INTO activity VALUES (date,time,activity,notes);""");

mysql.execute(sql)

conn.commit()
mysql.close()
conn.close()
%>


Sucess!


Thanks for any assistance.

B
--
http://mail.python.org/mailman/listinfo/python-list


Graph Dates and Values

2009-03-10 Thread brianrpsgt1
I am trying to plot dates and values on a graph using matplotlib.
Below is the code.  I can run this and it works great, until I get to
about 2000 rows from the DB.  Things really start to slow down.  I
have successfully plotted up to 5000 rows from the DB, but it is very
slow.  I am attempting to plot values for a day, which would be equal
to 84600 records.  Is there a more efficient may to accomplish this?

import os
import psycopg2
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import pylab
import dateutil
from datetime import datetime

conn = psycopg2.connect("dbname='db' user='user' password='somepass'
host='localhost'")

spo2_cur = conn.cursor()
sql = ("""SELECT System_Time, val1 FROM data WHERE DATE(System_Time)
='2009-01-07' AND Inst_Num='12345';""")

data_cur.execute(sql)

value_data = data_cur.fetchall()

data_cur.close()
conn.close()

num_rows = len(value_data)
print "There are",num_rows,"rows in the database"


datesFmt = mdates.DateFormatter('%H:%M')

plt.figure(figsize=(14,3))

for s in value_data:

dates = mdates.date2num([s[0]])

plt.plot([dates],[s[1]], 'bo', ms=6)

plt.ylim(60,100)
plt.axhline(y=90, linewidth=2, color='r')

ax1= plt.gca()
ax1.xaxis.set_major_formatter(datesFmt)

for label in ax1.xaxis.get_ticklabels():
label.set_color('black')
label.set_rotation(45)
label.set_fontsize(8)

for label in ax1.yaxis.get_ticklabels():
label.set_fontsize(8)

plt.show()
plt.close()


Any help would be great!

Thanks

B
--
http://mail.python.org/mailman/listinfo/python-list


Re: Graph Dates and Values

2009-03-10 Thread brianrpsgt1
On Mar 10, 7:40 am, "Gabriel Genellina" 
wrote:
> En Tue, 10 Mar 2009 05:08:41 -0200, brianrpsgt1   
> escribió:
>
> > I am trying to plot dates and values on a graph using matplotlib.
> > Below is the code.  I can run this and it works great, until I get to
> > about 2000 rows from the DB.  Things really start to slow down.  I
> > have successfully plotted up to 5000 rows from the DB, but it is very
> > slow.  I am attempting to plot values for a day, which would be equal
> > to 84600 records.  Is there a more efficient may to accomplish this?
>
> (isn't it 86400?)
>
> > for s in value_data:
> >     dates = mdates.date2num([s[0]])
> >     plt.plot([dates],[s[1]], 'bo', ms=6)
>
> Without looking at the matplotlib docs, the above [] suggests that both  
> date2num and plt.plot take a list of values to act upon, and you're  
> feeding one point at a time. Probably you end up creating one series per  
> point (instead of a single series with many points). I guess something  
> like this should work:
>
> x, y = zip(*value_data) # "transpose"
> dates = mdates.date2num(x)
> plt.plot(dates, y, 'bo', ms=6)
>
> (totally untested)
>
> --
> Gabriel Genellina

Gabriel ::

Thanks for the notes.  That is exactly what I thought the problem
was.  Here is an update.  I put a limit to 100 on the SQL Query to
test.  When I run your code, I get the data returned, however, I get
the same return equal to the limit I set.  In other words, when I run
with a limit of 100, I get the same result 100 times.  Which would
mean that when I try to run a whole day (86400 :) - it was late!), I
am getting the same result 86400 times and then it is tyring to plot
that.

Output below:

[ 733414.06489583  733414.06490741  733414.06491898  733414.06493056
  733414.06494213  733414.0649537   733414.06496528  733414.06497685
  733414.06498843  733414.065   733414.06501157  733414.06502315
  733414.06503472  733414.0650463   733414.06505787  733414.06506944
  733414.06508102  733414.06509259  733414.06510417  733414.06511574
  733414.06512731  733414.06513889  733414.06515046  733414.06516204
  733414.06517361  733414.06518519  733414.06519676  733414.06520833
  733414.06521991  733414.06523148  733414.06524306  733414.06525463
  733414.0652662   733414.06527778  733414.06528935  733414.06530093
  733414.0653125   733414.06532407  733414.06533565  733414.06534722
  733414.0653588   733414.06537037  733414.06538194  733414.06539352
  733414.06540509  733414.06541667  733414.06542824  733414.06543981
  733414.06545139  733414.06546296  733414.06547454  733414.06548611
  733414.06549769  733414.06550926  733414.06552083  733414.06553241
  733414.06554398  733414.0656  733414.06556713  733414.0655787
  733414.06559028  733414.06560185  733414.06561343  733414.065625
  733414.06563657  733414.06564815  733414.06565972  733414.0656713
  733414.06568287  733414.06569444  733414.06570602  733414.06571759
  733414.06572917  733414.06574074  733414.06575231  733414.06576389
  733414.06577546  733414.06578704  733414.06579861  733414.06581019
  733414.06582176  733414.0658  733414.06584491  733414.06585648
  733414.06586806  733414.06587963  733414.0658912   733414.06590278
  733414.06591435  733414.06592593  733414.0659375   733414.06594907
  733414.06596065  733414.06597222  733414.0659838   733414.06599537
  733414.06600694  733414.06601852  733414.06603009  733414.06604167]
(95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 94, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 94)

If I run this code:

for s in value_data:
x = mdates.date2num([s[0]])
y = [s[1]]

print [x, y]

The results returned are the following:

There are 100 rows in the database
[ 733414.06489583] [95]
[ 733414.06490741] [95]
[ 733414.06491898] [95]
[ 733414.06493056] [95]
[ 733414.06494213] [95]
[ 733414.0649537] [95]
[ 733414.06496528] [95]
[ 733414.06497685] [95]
[ 733414.06498843] [95]
[ 733414.065] [95]
[ 733414.06501157] [95]
[ 733414.06502315] [95]
[ 733414.06503472] [95]
[ 733414.0650463] [95]
[ 733414.06505787] [95]
[ 733414.06506944] [95]
[ 733414.06508102] [95]
[ 733414.06509259] [95]
[ 733414.06510417] [95]
[ 733414.06511574] [95]
[ 733414.06512731] [95]
[ 733414.06513889] [95]
[ 733414.06515046] [95]
[ 733414.06516204] [95]
[ 733414.06517361] [95]
[ 733414.06518519] [95]
[ 733414.06519676] [95]
[ 733414.06520833] [95]
[ 733414.06521991] [95]
[ 733414.06523148] [95]
[ 733414.06524306] [95]
[ 733414.06525463] [95]
[ 733414.0652662] [95]
[ 733414.06527778] [95]
[ 733414.06528935] [9

Re: Graph Dates and Values

2009-03-10 Thread brianrpsgt1
On Mar 10, 9:44 am, "Gabriel Genellina" 
wrote:
> En Tue, 10 Mar 2009 13:32:10 -0200, brianrpsgt1   
> escribió:
>
>
>
>
>
> > On Mar 10, 7:40 am, "Gabriel Genellina" 
> > wrote:
> >> En Tue, 10 Mar 2009 05:08:41 -0200, brianrpsgt1   
> >> escribió:
>
> >> > I am trying to plot dates and values on a graph using matplotlib.
> >> > Below is the code.  I can run this and it works great, until I get to
> >> > about 2000 rows from the DB.  Things really start to slow down.  I
> >> > have successfully plotted up to 5000 rows from the DB, but it is very
> >> > slow.  I am attempting to plot values for a day, which would be equal
> >> > to 84600 records.  Is there a more efficient may to accomplish this?
> >> Without looking at the matplotlib docs, the above [] suggests that both  
> >> date2num and plt.plot take a list of values to act upon, and you're  
> >> feeding one point at a time. Probably you end up creating one series  
> >> per  
> >> point (instead of a single series with many points). I guess something  
> >> like this should work:
>
> >> x, y = zip(*value_data) # "transpose"
> >> dates = mdates.date2num(x)
> >> plt.plot(dates, y, 'bo', ms=6)
>
> > Thanks for the notes.  That is exactly what I thought the problem
> > was.  Here is an update.  I put a limit to 100 on the SQL Query to
> > test.  When I run your code, I get the data returned, however, I get
> > the same return equal to the limit I set.  In other words, when I run
> > with a limit of 100, I get the same result 100 times.  Which would
> > mean that when I try to run a whole day (86400 :) - it was late!), I
> > am getting the same result 86400 times and then it is tyring to plot
> > that.
>
> > Output below:
>
> > [ 733414.06489583  733414.06490741  733414.06491898  733414.06493056 ...
> >   733414.06600694  733414.06601852  733414.06603009  733414.06604167]
> > (95, 95, 95, 95, ...  95, 95, 95, 94)
>
> > If I run this code:
>
> > for s in value_data:
> >     x = mdates.date2num([s[0]])
> >     y = [s[1]]
> >     print [x, y]
>
> > The results returned are the following:
>
> > There are 100 rows in the database
> > [ 733414.06489583] [95]
> > [ 733414.06490741] [95]
> > [ 733414.06491898] [95]
> > [ 733414.06493056] [95] ...
> > [ 733414.06600694] [95]
> > [ 733414.06601852] [95]
> > [ 733414.06603009] [95]
> > [ 733414.06604167] [94]
>
> Well, both look the same values to me... what's wrong? Why do you say "the  
> same results 100 times".
>
> Oh, the code fragment I posted is suposed to *replace* the original for  
> loop. Don't put it inside a loop.
>
> --
> Gabriel Genellina

Gabriel ::

Thank you very much!!!  That was it, I had it in the loop.  I works
great now!!  Graphs are coming up right away.

B
--
http://mail.python.org/mailman/listinfo/python-list


Problems downloading and installing win32api

2008-09-08 Thread brianrpsgt1
I have attempted downloading and installing several different version
of the win32api from Source Forge, however, each time I try to install
I get the following error message:

"Only part of a ReadProcessMemory or WriteProcessMemory request was
completed"

This occurred with the following files:
pywin32-212.win32-py2.4.exe
pywin32-212.win32-py2.5.exe
pywin32-212.win32-py2.6.exe

I am using WinXP SP2.  Any assistance on getting this downloaded and
installed would be great.

Thanks

B
--
http://mail.python.org/mailman/listinfo/python-list