Nathan Spencer | 21 Oct 23:14 2014
Picon

Full screen mode

Hi there,

I'm running python on Scientific Linux.  The problem is that I'm permanently stuck in full screen mode.  Exiting out of that mode (via F11) doesn't do anything.  Do you have any suggestions?

Thanks,
Nathan

--
Nathaniel J. Spencer, PhD
Post-Doctoral Research Associate
Psychoacoustics Lab
School of Health and Rehabilitative Sciences
University of Pittsburgh
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Al Bull | 21 Oct 20:57 2014

Question on a select statement with ODBC

Windows 7.0
Python 3.3.4

I am accessing a database table via ODBC.   The table I am accessing can
have multiple records per ord_dbasub.  Is there a way I can structure the
select statement to retrieve only the most current record (based on
ord_date)?

I used to program in PL/I and assembly in the old days but my knowledge of
SQL and Python is still pretty limited.   Here is what I have so far..

import pyodbc
cnxn = pyodbc.connect("DSN=Quickfill DEMO Database")
cursor = cnxn.cursor()

ord_rows = cursor.execute("select ord_dbasub, ord_pub,
ord_date,ord_service,"
                          "ord_agency, ord_woa, ord_status,"
                          "ord_channel, ord_source, ord_giftcomp,"
                          "ord_cnreason "
                          "from ord "
                          "Where ord_pub='QWKFIL'"
                          "order by ord_dbasub, ord_date").fetchall()

for row in ord_rows:
   # Print for testing.  Remove later
   print (row.ord_dbasub, row.ord_date, row.ord_pub)
   # Add code here to find the most recent order per DBASUB and delete other
orders
   # Also add exclusion code to be applied to survivor record

This code works so far.   I just need to determine how to remove all but the
most current record per ord_dbasub.    Assuming I can't remover it via the
select statement I'll have to traverse the array (Tuples in Python,
correct?) and remove the ones I don't need.   What's the best way to do
that?

I have to admit that the concept of tuples & dictionaries has me a little
bit confused.    I'm used to working with arrays and arrays of structures.

Thanks in advance for your help!

Al Bull, Chief Technology Officer/Owner
Publishers Data Management Group

a.bull <at> pubdmgroup.com
815-732-5297

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Crush | 21 Oct 01:28 2014
Picon

Re: Insert time into email

Hey thanks for the help, it worked like a charm. I will post the complete code soon, so others may benefit
should they ever need it. 

Thanks again. 
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Picon

Re: Insert time into email

Forwarding to list — please use Reply All… next time.

On Mon, Oct 20, 2014 at 6:28 PM, Crush <crushed26 <at> gmail.com> wrote:
> Where does the ."format(time=t,date=d)" go?
>
> I would assume something like
>
> msgTime = MIMEText()
> msgTime.add_header('not sure what to put here?' '<time>' .format(time=t))
> msgRoot.attach(msgTime)
>
> then in the actual html, something like...
> <table><tr><td>{time}</td></tr></table>?
>
> and yes, for simplicity sake, the date and time will be the same.

Do not bother with MIME for this.  It WON’T be simpler.  (it’s most
likely impossible, in fact.)

msgText = MIMEText('<table cellspacing="15" border="1">…rest of your
HTML here, complete with {time} and {date}
tags…</table>'.format(time=t, date=d), 'html')
msgAlternative.attach(msgText)

--

-- 
Chris “Kwpolska” Warrick <http://chriswarrick.com/>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Juan Christian | 20 Oct 19:04 2014
Picon

Python sqlite3 issue

I have this code (http://pastebin.com/Q21vQdHZ):

import sqlite3

db = sqlite3.connect('db.sqlite')


def create_db():
    db.execute('''
    CREATE TABLE TOPICS(
    ID INT PRIMARY KEY NOT NULL,
    URL VARCHAR NOT NULL,
    AUTHOR VARCHAR NOT NULL,
    MESSAGE VARCHAR NOT NULL
    );
    ''')


def insert_db(_id, url, author, message):
    db.execute("INSERT INTO TOPICS (ID, URL, AUTHOR, MESSAGE) VALUES ({}, {}, {}, {})".format(_id, url, author, message))
    db.commit()


def get_db(_id):
cursor = db.execute("SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS WHERE ID = {}".format(_id))
return cursor.fetchone()


if __name__ == '__main__':
create_db()
insert_db(12, 'abc.com', 'a', 'b')
get_db(12)
db.close()

And when I try to execute it I get:

First time executing:

Traceback (most recent call last):
  File ".\sql.py", line 29, in <module>
    insert_db(12, 'abc.com', 'a', 'b')
  File ".\sql.py", line 18, in insert_db
    db.execute("INSERT INTO TOPICS (ID, URL, AUTHOR, MESSAGE) VALUES ({}, {}, {}, {})".format(_id, url, author, message)
)
sqlite3.OperationalError: no such column: abc.com


Second time executing:

Traceback (most recent call last):
  File ".\sql.py", line 28, in <module>
    create_db()
  File ".\sql.py", line 14, in create_db
    ''')
sqlite3.OperationalError: table TOPICS already exists


What's the problem? It's just a test script just to learn sqlite3 with python.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Bo Morris | 20 Oct 14:34 2014
Picon

Insert time into email

hello all, hope everyone is doing well. 

The below code works, however I am going back and trying to enter the time and date and I cant quite figure out how to do this without breaking the code. 

#!/usr/bin/python

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
import time

strFrom = "HourlyReport.com"


l = ['3102EHD-01108.png', '3102DHD-01109.png','3102EHD-01082.png', '3102DHD-01033.png', '3102EHD-01302.png', '3102DHD-01149.png', '3102EHD-01125.png', '3102DHD-01144.png', '3102EHD-01105.png'] 

t = time.strftime("%H:%M:%S")
d = time.strftime("%d/%m/%Y")

msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = 'Test Hourly Report'
msgRoot['From'] = strFrom
msgRoot['To'] = strTo
msgRoot.preamble = 'This is a multi-part message in MIME format.'

msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)

msgText = MIMEText('This is the alternative plain text message.')
msgAlternative.attach(msgText)

msgText = MIMEText('<table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01108.png" width="400" height="300"></img><table><tr><td>TIME<td><td>DATE</td></td></tr></table></td><td><img src="cid:3102DHD-01109.png" width="400" height="300"></img><table><tr><td>TIME<td><td>DATE</td></td></tr></table></td></tr><table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01082.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td><td><img src="cid:3102DHD-01033.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr></table><table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01302.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td><td><img src="cid:3102DHD-01149.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr><table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01125.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td><td><img src="cid:3102DHD-01144.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr></td></tr></table><table cellspacing="15" border="1"><tr><td><img src="cid:3102DHD-01144.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr></table>', 'html')
msgAlternative.attach(msgText)

for image in l:
    with open(image, 'rb') as fh:
        msgImage = MIMEImage(fh.read())
        msgImage.add_header('Content-ID', '<{0}>'.format(image))
        msgRoot.attach(msgImage)
        

try:
   smtpObj = smtplib.SMTP('localhost')
   smtpObj.sendmail(strFrom, strTo, msgRoot.as_string())         
   print "Successfully sent email"
except smtplib.SMTPException:
   print "Error: unable to send email"

I need to enter the time and date in the html where "TIME" and "DATE" are. I imagine I can do this by adding "cid: t" and "cid:d" which just refers back to t = "time.strftime("%H:%M:%S")" "d = time.strftime("%d/%m/%Y")"?

Thanks in advance for any help. 
 
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Taylor Ruzgys | 20 Oct 04:56 2014
Picon

Python Help

Hi, I was wondering if you could help me with an assignment that I'm doing involving Python?
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Clayton Kirkwood | 20 Oct 00:26 2014
Picon

what am I not understanding?

raw_table = ('''

a: Ask    y: Dividend Yield

b: Bid     d: Dividend per Share

b2: Ask (Realtime)           r1: Dividend Pay Date

b3: Bid (Realtime)            q: Ex-Dividend Date

p: Previous Close

o: Open’’’)

 

key_name = raw_table.rstrip('\t')

print(key_name)

 

a: Ask    y: Dividend Yield

b: Bid     d: Dividend per Share

b2: Ask (Realtime)           r1: Dividend Pay Date

b3: Bid (Realtime)            q: Ex-Dividend Date

p: Previous Close

o: Open                                                #why is the tab not being removed?

 

 

key_name = raw_table.rstrip('\n')

print(key_name)

 

a: Ask    y: Dividend Yield

b: Bid     d: Dividend per Share

b2: Ask (Realtime)           r1: Dividend Pay Date

b3: Bid (Realtime)            q: Ex-Dividend Date

p: Previous Close

o: Open                                                # why is the \n not being removed?

 

key_name = raw_table.split('\t')

print(key_name)

 

['\na: Ask', 'y: Dividend Yield\nb: Bid', 'd: Dividend per Share\nb2: Ask (Realtime)', 'r1: Dividend Pay Date\nb3: Bid (Realtime)'…

                                #great the tab is being removed but now I have to remove the \n but it is no longer a string

 

key_name = raw_table.split('\n')

print(key_name)

['', 'a: Ask\ty: Dividend Yield', 'b: Bid\td: Dividend per Share', 'b2: Ask (Realtime)\tr1: Dividend Pay Date', 'b3: Bid (Realtime)\tq: Ex-Dividend Date'…

                                #great, the \n is being “removed” but now I have to remove the \t, but it is no longer a string

 

key_name = raw_table.split('\t\n')

print(key_name)

['\na: Ask\ty: Dividend Yield\nb: Bid\td: Dividend per Share\nb2: Ask (Realtime)\tr1: Dividend Pay Date\nb3: Bid (Realtime)\tq: Ex-Dividend Date\n…

                                #why isn’t the \t and \n not both “removed”

 

key_name = raw_table.rstrip('[\t\n]')

a: Ask    y: Dividend Yield

b: Bid     d: Dividend per Share

b2: Ask (Realtime)           r1: Dividend Pay Date

b3: Bid (Realtime)            q: Ex-Dividend Date

p: Previous Close

o: Open                                #why aren’t both the \t and \n being removed? (tried with and without the square brackets)

 

I am trying to get to where I can create a dict using the ‘:’ separator

 

Thanks

 

Clayton

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
AMNA MOHAMMED ALRUHEILI | 19 Oct 16:27 2014
Picon

Need help to convert pdf to excel

Hell,
My name is Amna and I am totally new to python world with zero experience in programming. I am facing the challenge of converting data from pdf to excel. The data within pdf is numbers separated by space not within a table.
I need a help to figure out a code that help me to convert these pdf to excel.

How can I do that.
Thank you,
Amna
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Joel Goldstick | 19 Oct 15:43 2014
Picon

Re: python draw christman tree using loops

On Sun, Oct 19, 2014 at 9:27 AM, jarod_v6 <at> libero.it <jarod_v6 <at> libero.it> wrote:
> thanks for the help:
> In [60]: for i in range(10):
>    ....:   for t in range(6-i):
>    ....:       print " "
>    ....:       for item in range(i+1):
>    ....:           print "*"
>    ....:
>
> *
>
> *
>
> *
>
> *
>
> *
>
> *
>
> *
> *
>
> *
> *
>
> *
> *
>
> *
> *
>
> *
> *
>
> *
> *
> *
>
> *
> *
> *
>
> *
> *
> *
>
> *
> *
> *
>
> *
> *
> *
> *
>
> *
> *
> *
> *
>
> *
> *
> *
> *
>
> *
> *
> *
> *
> *
>
> *
> *
> *
> *
> *
>
> *
> *
> *
> *
> *
> *
>
> this i the output.. it is not a tree..
>
>
>>----Messaggio originale----
>>Da: joel.goldstick <at> gmail.com
>>Data: 19/10/2014 14.10
>>A: "jarod_v6 <at> libero.it"<jarod_v6 <at> libero.it>
>>Cc: <tutor-request <at> python.org>, "tutor <at> python.org"<tutor <at> python.org>
>>Ogg: Re: [Tutor] python draw christman tree using loops
>>
>>On Sun, Oct 19, 2014 at 7:32 AM, jarod_v6 <at> libero.it <jarod_v6 <at> libero.it>
> wrote:
>>>
>>> Dear All,
>>> or improve my understanding o python I would like to learn how to draw
> simple
>>> figures using loops.
>>> I start from this code in java:
>>> import java.util.Scanner;
>>>
>>> public class Eserc2_8 {
>>>     public static void main(String args[]) {
>>>         Scanner s = new Scanner(System.in);
>>>         // Altezza del triangolo
>>>         int altezza = s.nextInt();
>>>
>>>         for (int riga = 1; riga <= altezza; riga++) {
>>>             int i = 0;
>>>             while (i<altezza-riga) {
>>>                 System.out.print(" ");
>>>                 i += 1;
>>>             }
>>>             i = 0;
>>>             while (i< (riga*2)-1) {
>>>                 System.out.print("*");
>>>                 i += 1;
>>>             }
>>>             System.out.println("");
>>>         }
>>>     }
>>> }
>>>
>>> and I want to transfer to python loops:
>>>
>>> for i in range(10):
>>>     #space
>>>     for t in range(6-i):
>>>         print ""
>>>         for item in range(i+1):
>>>             print "."
>>>
>>>
>>> But I ha not succed. So someone could you please explain how can work'
>>> thanks  a lot
>>> bw
>>>
>>what is your output?  What errors (print complete traceback)
>>
>>You probably want print " ", and print ".",  so that there is no added
> newline.
>>>

In python 2.x you can add a comma to the print statement so that it
will not generate a newline.  That way your *s will print across.
After you loop use plain print to go to next line.

Also, reply to the list, not to me.
>>>
>>> _______________________________________________
>>> Tutor maillist  -  Tutor <at> python.org
>>> To unsubscribe or change subscription options:
>>> https://mail.python.org/mailman/listinfo/tutor
>>
>>
>>
>>--
>>Joel Goldstick
>>http://joelgoldstick.com
>>
>
>

--

-- 
Joel Goldstick
http://joelgoldstick.com
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

George R Goffe | 19 Oct 14:32 2014

A question about using stdin/out/err vs named files

Hi,

Wow. Lots of feedback. REALLY GOOD FEEDBACK!

This was my first question to this list. Let me clarify my question.

I want to use tst.py as follows:

tst.py input-file output-file OR
cat data-file | tst.py - output-file OR
cat data-file | tst.py output-file

tst.py input-file output-file works well
tst.py - output-file works well

The question boils down to "tst.py output-file"... which is a "parsing the args" question which you "guys"
have caused me to think more clearly about. If there's just 1 arg, consider it an output-file and read from
stdin and write to output-file ONLY if output-file does not exist.

Thank you all for your very helpful and informative responses.

Regards,

George...
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Gmane