Getting importError: No module named _md5

2007-06-27 Thread jeffself
I'm running Python 2.5.1 which I'm getting from the MacPort package
system.  I just installed Django and tried to start up the Django
server and I got the following error:

ImportError: No module named _md5

I'm pretty sure this is a python problem, not Django problem. I'm
looking in the python2.5 directory and I see md5.py, md5.pyc and
md5.pyo files.

Any suggestions?

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


Re: Getting importError: No module named _md5

2007-06-27 Thread jeffself
On Jun 27, 11:54 am, [EMAIL PROTECTED] wrote:
> On Jun 27, 7:04 am, jeffself <[EMAIL PROTECTED]> wrote:
>
> > I'm running Python 2.5.1 which I'm getting from the MacPort package
> > system.  I just installed Django and tried to start up the Django
> > server and I got the following error:
>
> > ImportError: No module named _md5
>
> > I'm pretty sure this is a python problem, not Django problem. I'm
> > looking in the python2.5 directory and I see md5.py, md5.pyc and
> > md5.pyo files.
>
> > Any suggestions?
>
> Try to load the md5 module from the interactive prompt.  Are you using
> the python version you expect?  Try starting up your previous version
> of python and see if you get the same error.  Delete the MacPort
> install and install from source.
>
> My 2 cents.
>
> ~Sean

I reinstalled Python from source and it worked.  Thanks!

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


Re: Python PDF + Pictures

2008-03-11 Thread jeffself
On Mar 11, 5:00 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hi, dear Python Masters!
>
> I wanna ask about the Python and PDF creating.
>
> I have many photos, and I wanna make some "presentation" from these
> photos, a "thumbnail" like document with one image per one page.
>
> If I wanna make one document now I do this:
> I execute a python script that create a html site with resized pictures,
> and split this html site to 50 images per one html file.
> Next I open these files in OpenOffice Writer by hand, and save them as
> PDF document with poor quality (image compression 95%, image DPI 75).
> This generates a medium sized PDF documents (2,5 - 5,6 MB for each) that
> can opened everywhere (because of PDF format).
>
> But I wanna automatize this process with python.
> The technic that I will use is this:
> 1.) Collect the files in dirs.
> 2.) I process one dir in one time.
> 3.) I get the files.
> 4.) I resize them to max. 1024/768.
> 5.) I put the actual image file to the PDF document.
> 6.) After each 50. file I open new numbered PDF.
> 7.) Every picture placed in one page, and every page orientation set up
> as the picture orientation (Portrait or Landscape).
>
> The PDF must be parameterized to image compression 95%, and 75 or 96 DPI.
>
> Do you knows about a PDF maker library with I can make this thing?
>
> Or other technic to simplify the making?
>
> Thanks for your help!
>dd

You might also want to take a look at ReportLab.  Its a PDF library
for Python.  You can find it at http://www.reportlab.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


How can I use quotes without escaping them using CSV?

2008-04-09 Thread jeffself
I'm reading data out of an Excel spreadsheet using the XLRD module.
The spreadsheet contains a list of election results.  The fields are
as follows: Precinct, Candidate, Votes

The problem is candidate names can be funky, for instance:  Michael L.
"Mick" Jones

I cannot for the life of me figure out how to get the CSV module to
allow a name like this to be written to a file.  Why does it insist on
an escape character when I'm telling it that the delimiter should be
'\t'?  I want the quotes to go to the file and I want the tab-
delimited file to look like this:

0001[tab]Michael L. "Mick" Jones[tab]189
0002[tab]Vickie A. Meyers[tab]221
0003[tab]John "Jack" Smith[tab]187

Note: I don't want [tab] to display, I want a real tab there.

If I put an escape character in, it works.  For example, if I use ~ as
my escape character, my output looks like this:
0001[tab]Michael L. ~"Mick~" Jones[tab]189

I don't want that. If I don't include an escape character, it doesn't
work.


Here's my code:
import sys
import csv
from readexcel import *

f = open("results.txt", 'wb')
book = sys.argv[1]
sheet = sys.argv[2]

xl = readexcel(book)
sheetnames = xl.worksheets()

for s in sheetnames:
if s == sheet:
writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in xl.getiter(s):
 
writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Votes']
f.close()


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


Re: How can I use quotes without escaping them using CSV?

2008-04-09 Thread jeffself
On Apr 9, 5:39 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:python-
> > [EMAIL PROTECTED] On Behalf Of jeffself
> > Sent: Wednesday, April 09, 2008 5:11 PM
> > To: [EMAIL PROTECTED]
> > Subject: How can I use quotes without escaping them using CSV?
>
> > If I put an escape character in, it works.  For example, if I use ~ as
> > my escape character, my output looks like this:
> > 0001[tab]Michael L. ~"Mick~" Jones[tab]189
>
> > I don't want that. If I don't include an escape character, it doesn't
> > work.
>
> > Here's my code:
> > import sys
> > import csv
> > from readexcel import *
>
> > f = open("results.txt", 'wb')
> > book = sys.argv[1]
> > sheet = sys.argv[2]
>
> > xl = readexcel(book)
> > sheetnames = xl.worksheets()
>
> > for s in sheetnames:
> > if s == sheet:
> > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE)
> > for row in xl.getiter(s):
>
> writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote
>
> > s']
> > f.close()
>
> The documentation is pretty, uhm, obtuse, but you also need to set
> quotechar.
>
> import sys
> import csv
>
> names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack"
> Smith']
>
> writer = csv.writer(sys.stdout, delimiter='\t', quotechar='',
> quoting=csv.QUOTE_NONE)
> for i in names:
> writer.writerow(['a', i, 'b'])
>
> output:
> a   Michael L. "Mick" Jones b
> a   Vickie A. Meyersb
> a   John "Jack" Smith   b
>
> *
>
> The information transmitted is intended only for the person or entity to 
> which it is addressed and may contain confidential, proprietary, and/or 
> privileged material. Any review, retransmission, dissemination or other use 
> of, or taking of any action in reliance upon this information by persons or 
> entities other than the intended recipient is prohibited. If you received 
> this in error, please contact the sender and delete the material from all 
> computers. GA621

I tried this but a get the following error:
>>> writer = csv.writer(sys.stdout, delimiter='\t', quotechar=", 
>>> quoting=csv.QUOTE_NONE)
  File "", line 1
writer = csv.writer(sys.stdout, delimiter='\t', quotechar=",
quoting=csv.QUOTE_NONE)
 
^
SyntaxError: EOL while scanning single-quoted string
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I use quotes without escaping them using CSV?

2008-04-09 Thread jeffself
On Apr 9, 5:39 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:python-
> > [EMAIL PROTECTED] On Behalf Of jeffself
> > Sent: Wednesday, April 09, 2008 5:11 PM
> > To: [EMAIL PROTECTED]
> > Subject: How can I use quotes without escaping them using CSV?
>
> > If I put an escape character in, it works.  For example, if I use ~ as
> > my escape character, my output looks like this:
> > 0001[tab]Michael L. ~"Mick~" Jones[tab]189
>
> > I don't want that. If I don't include an escape character, it doesn't
> > work.
>
> > Here's my code:
> > import sys
> > import csv
> > from readexcel import *
>
> > f = open("results.txt", 'wb')
> > book = sys.argv[1]
> > sheet = sys.argv[2]
>
> > xl = readexcel(book)
> > sheetnames = xl.worksheets()
>
> > for s in sheetnames:
> > if s == sheet:
> > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE)
> > for row in xl.getiter(s):
>
> writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote
>
> > s']
> > f.close()
>
> The documentation is pretty, uhm, obtuse, but you also need to set
> quotechar.
>
> import sys
> import csv
>
> names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack"
> Smith']
>
> writer = csv.writer(sys.stdout, delimiter='\t', quotechar='',
> quoting=csv.QUOTE_NONE)
> for i in names:
> writer.writerow(['a', i, 'b'])
>
> output:
> a   Michael L. "Mick" Jones b
> a   Vickie A. Meyersb
> a   John "Jack" Smith   b
>
> *
>
> The information transmitted is intended only for the person or entity to 
> which it is addressed and may contain confidential, proprietary, and/or 
> privileged material. Any review, retransmission, dissemination or other use 
> of, or taking of any action in reliance upon this information by persons or 
> entities other than the intended recipient is prohibited. If you received 
> this in error, please contact the sender and delete the material from all 
> computers. GA621

I set quotechar="" and was able to get it to work.  I'll try this at
work tomorrow!
-- 
http://mail.python.org/mailman/listinfo/python-list