reading txt file

2012-05-31 Thread Ahmed, Shakir
HI:
I am trying to read a txt file and dump the columns in an access database 
table. But getting problem:

 Unhandled exception while debugging...
Traceback (most recent call last):
  File C:\WindDuration\Reading_test.py, line 14, in module
my_length_1 = nmAddrList[1]
IndexError: list index out of range

Getting error when it is reading to second line.

The txt file is attached here and I need only 2,8,11,14,15 columns to dump in 
the table.


Any help is highly appreciated.

Thanks
sa



We value your opinion. Please take a few minutes to share your comments on the 
service you received from the District by clicking on this 
linkhttp://my.sfwmd.gov/portal/page/portal/pg_grp_surveysystem/survey%20ext?pid=1653.
FL Dade   Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  88kt 10/24 07

FL Monroe Existing   Existing   Existing   10/24 11E [04]  
10/24 12E [05]  10/24 15E [08]  94kt 10/24 07

FL CollierExisting   Existing   Existing   10/24 12E [05]  
10/24 13E [06]  10/24 15E [08]  104kt 10/24 0

FL BrowardExisting   Existing   Existing   10/24 13E [06]  
10/24 14E [07]  10/24 16E [09]  93kt 10/24 08

FL LeeExisting   Existing   Existing   10/24 10E [03]  
10/24 12E [05]  10/24 15E [08]  89kt 10/24 07

FL Hendry Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  100kt 10/24 0

FL Palm Beach Existing   Existing   Existing   10/24 14E [07]  
10/24 15E [08]  10/24 17E [10]  93kt 10/24 08

FL Charlotte  Existing   Existing   Existing   10/24 10E [03]  
10/24 12E [05]  10/24 15E [08]  76kt 10/24 07

FL Glades Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  91kt 10/24 09

FL Martin Existing   Existing   Existing   10/24 14E [07]  
10/24 15E [08]  10/24 17E [10]  92kt 10/24 11

FL St Lucie   Existing   Existing   10/24 08E  10/24 14E [06]  
10/24 15E [08]  10/24 17E [10]  89kt 10/24 11

FL Okeechobee Existing   Existing   Existing   10/24 13E [06]  
10/24 15E [08]  10/24 17E [10]  83kt 10/24 09

FL Highlands  Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  74kt 10/24 09

FL Desoto Existing   Existing   Existing   10/24 09E [02]  
10/24 12E [05]  10/24 15E [08]  67kt 10/24 08

FL Sarasota   Existing   Existing  
10/24 11E [04]  10/24 15E [08]  59kt 10/24 07

FL ManateeExisting   Existing  
10/24 11E [04]  10/24 15E [08]  56kt 10/24 07

FL Hardee Existing   Existing  
10/24 12E [05]  10/24 16E [09]  60kt 10/24 08

FL Pinellas   Existing  
   10/24 13E [06]  43kt 10/24 07

FL HillsborougExisting   Existing  
10/24 08E [01]  10/24 15E [08]  50kt 10/24 07

FL Polk   Existing   Existing  
10/24 13E [06]  10/24 16E [09]  60kt 10/24 09

FL OsceolaExisting   Existing   10/24 10E  10/24 11E [01]  
10/24 14E [07]  10/24 17E [10]  64kt 10/24 10

FL Indian RiveExisting   Existing   10/24 09E  10/24 14E [05]  
10/24 15E [08]  10/24 17E [10]  76kt 10/24 11

FL BrevardExisting   Existing   10/24 10E  10/24 13E [03]  
10/24 15E [08]  10/24 18E [11]  67kt 10/24 11

FL Orange Existing   10/24 09E 
10/24 13E [04]  10/24 17E [10]  53kt 10/24 11

FL Seminole   Existing  
   10/24 17E [10]  48kt 10/24 10

FL Lake   Existing  
   10/24 16E [09]  46kt 10/24 09

FL Sumter Existing  
   10/24 15E [08]  43kt 10/24 08

FL Pasco  Existing  
   10/24 15E [08]  43kt 10/24 08

FL Hernando   Existing  
   10/24 15E [08]  40kt 10/24 08

FL Citrus Existing  
   10/24 13E [06]  37kt 10/24 10

FL Marion Existing  
   10/24 15E [08]  39kt 10/24 10

FL VolusiaExisting  
   10/24 18E [11]  48kt 10/24 10

FL Flagler10/24 08E 
   10/24 16E [08]  40kt 10/24 11

FL Putnam 10/24 09E 
   10/24 16E [07]  38kt 10/24 12

FL St Johns   10/24 11E 
   

unzip problem

2011-06-24 Thread Ahmed, Shakir
Hi,

 

I am getting following error message while unziping a .zip file. Any
help or idea is highly appreciated.

 

Error message

Traceback (most recent call last):

  File C:\Zip_Process\py\test2_new.py, line 15, in module

outfile.write(z.read(name))

IOError: (22, 'Invalid argument')

 

 

The script is here:

*

fh = open('T:\\test\\*.zip', 'rb')

z = zipfile.ZipFile(fh)

for name in z.namelist():

outfile = open(name, 'wb')

 

outfile.write(z.read(name))

print z

print outfile

outfile.close()

 

fh.close()



 

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


RE: unzip problem

2011-06-24 Thread Ahmed, Shakir
On Fri, 24 Jun 2011 10:55:52 -0400, Ahmed, Shakir wrote:

 Hi,
 
 
  
 I am getting following error message while unziping a .zip file. Any
 help or idea is highly appreciated.

How do you know it is when unzipping the file? Maybe it is, or maybe it 
isn't. The line giving the error has *two* IO operations, a read and a 
write. Either one could give IOError.

outfile.write(z.read(name))
IOError: (22, 'Invalid argument')

The first thing is to isolate what is causing the error:

data = z.read(name)
outfile.write(data)

Now you can be sure whether it is the read or the write  which causes
the 
error.

Secondly, find out what the argument is. Assuming it is the read, try 
this:

print repr(name)

Can you open the zip file in Winzip or some other zip utility? Does it 
need a password? 

I see you do this:

fh = open('T:\\test\\*.zip', 'rb')

Do you really have a file called *.zip? I find that very hard to 
believe... as I understand it, * is a reserved character in Windows and 
you cannot have a file with that name.

My guess is that the actual error is when you try to open the file in
the 
first place, before any unzipping takes place, but you've messed up the 
line numbers (probably by editing the file after importing it).


-- 
Steven


The problem is happening when it is coming to write option.

The * is not the real name of the zip file, I just hide the name.

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


RE: unzip problem

2011-06-24 Thread Ahmed, Shakir


-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Philip Semanchuk
Sent: Friday, June 24, 2011 11:18 AM
To: Lista-Comp-Lang-Python list
Subject: Re: unzip problem


On Jun 24, 2011, at 10:55 AM, Ahmed, Shakir wrote:

 Hi,
 
 
 
 I am getting following error message while unziping a .zip file. Any
 help or idea is highly appreciated.
 
 
 
 Error message
 
 Traceback (most recent call last):
 
  File C:\Zip_Process\py\test2_new.py, line 15, in module
 
outfile.write(z.read(name))
 
 IOError: (22, 'Invalid argument')


Start debugging with these two steps --
1) Add this just after for name in z.namelist():
   print name

That way you can tell which file is failing.

2) You can't tell whether you're getting an error on the write or the
read because you've got two statements combined into one line. Change
this --
   outfile.write(z.read(name))
to this --
   data = z.read(name)
   outfile.write(data)


Good luck
Philip

 
 
 
 
 
 The script is here:
 
 *
 
 fh = open('T:\\test\\*.zip', 'rb')
 
 z = zipfile.ZipFile(fh)
 
 for name in z.namelist():
 
outfile = open(name, 'wb')
 
 
 
outfile.write(z.read(name))
 
print z
 
print outfile
 
outfile.close()
 
 
 
 fh.close()
 
 


The problem found in outfile.Write. The error code is here and is
happening when few of the files are already unzipped from the zip file

 T:\applications\tst\py\Zip_Process
 drg100.aux
 zipfile.ZipFile instance at 0x00E2F648
 open file 'drg100.aux', mode 'wb' at 0x00E12608
 drg100.fgdc.htm
 zipfile.ZipFile instance at 0x00E2F648
 open file 'drg100.fgdc.htm', mode 'wb' at 0x00E128D8
 drg100.htm
 zipfile.ZipFile instance at 0x00E2F648
 open file 'drg100.htm', mode 'wb' at 0x00E12608
 drg100.sdw
 zipfile.ZipFile instance at 0x00E2F648
 open file 'drg100.sdw', mode 'wb' at 0x00E128D8
 drg100.sid
 Unhandled exception while debugging...
Traceback (most recent call last):
  File C:\Zip_Process\py\test2_new.py, line 16, in module
outfile.write(data)
IOError: (22, 'Invalid argument')
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: unzip problem - solved

2011-06-24 Thread Ahmed, Shakir
-Original Message-
From: Ethan Furman [mailto:et...@stoneleaf.us] 
Sent: Friday, June 24, 2011 3:47 PM
To: Ahmed, Shakir
Cc: Python
Subject: Re: unzip problem

Ahmed, Shakir wrote:
 Thanks once again and you are right I am trying to unzip in the
network
 share drive. here is the script now: If I am doing any wrong. :
 ## code start here
 
 import zipfile
 import os
 import time
 dir1 = T:\\applications\\tst\\py\\Zip_Process
 test = '%s/shp'%dir1
 os.chdir(test)
 cwd = os.getcwd()
 print cwd
 
 
 CHUNK_SIZE = 10 * 1024 * 1024
 
 
 fn = open('T:\\applications\\tst\\py\\Zip_Process\\Zip\\myzip.zip',
 'rb')
 z = zipfile.ZipFile(fn)
 for name in z.namelist():
 ptr = 0
 data = z.read(name)
 size = len(data)
 print size
 print ptr
 while ptr  size:
 
 fn.write(data[ptr:ptr+CHUNK_SIZE])
 ptr += CHUNK_SIZE
 
 fn.close()
 
 #Code done here.
  
 But got error as follows:
 
 T:\applications\tst\py\Zip_Process\shp
 59160
 0
 Traceback (most recent call last):
   File

C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py
 , line 325, in RunScript
 exec codeObject in __main__.__dict__
   File t:\scratch\shahmed\test2_new.py, line 24, in module
 fn.write(data[ptr:ptr+CHUNK_SIZE])
 IOError: [Errno 9] Bad file descriptor

I didn't notice this in your last post, but you are using fn as both the

zipfile name and the name of the file you are writing to.  You'll need 
to create the file you want to write before you write to it (plus any 
intermediate directories).


Here's the (slightly stripped) version I actually use:

8
import os
from zipfile import  ZipFile

def retrieve_files(zipped, destination, files=None):
 retrieves files from zipped
 CHUNK_SIZE = 10 * 1024 * 1024
 try:
 os.makedirs(destination)
 except WindowsError:
 pass
 target = ZipFile(zipped, 'r')
 stored = dict([(k.filename.lower(), k.filename) for k in 
target.infolist()])
 if files is None:
 files = [member.filename.lower() for member in
target.infolist()]
 elif isinstance(files, (str, unicode)):
 files = [files.lower()]
 else:
 files = [f.lower() for f in files]
 for compressed_file in files:
 uncompressed_file = os.path.join(destination, compressed_file)
 path, filename = os.path.split(uncompressed_file)
 if not os.path.exists(path):
 os.makedirs(path)
 if filename == '__empty__':
 continue
 data = target.read(stored[compressed_file])
 fn = open(uncompressed_file, 'wb')
 ptr = 0
 size = len(data)
 while ptr  size:
 fn.write(data[ptr:ptr+CHUNK_SIZE])
 ptr += CHUNK_SIZE
 fn.close()
 target.close()
8

I convert all filenames to lower case since MS Windows doesn't care, but

Python does.

The test for filename == '__empty__': when I create the zipfile, if the 
directory is empty I store a 0-length file named '__empty__' in that 
subdirectory (actually, it only happens in the zipfile) so that I can 
get the directory back later.

Hope this helps.

~Ethan~

Thanks a lot to Ethan who really helped to find out the clue in the
code.
Here is the final code that worked to unzip a large file in the network
drive.

CHUNK_SIZE = 10 * 1024 * 1024


fh = open('T:\\applications\\tst\\py\\Zip_Process\\Zip\\myzip.zip',
'rb')
z = zipfile.ZipFile(fh)
for name in z.namelist():
fn = open(name, 'wb')
ptr = 0
data = z.read(name)
size = len(name)  
print size
print ptr
while ptr  size:
#fn.write(data)
fn.write(data[ptr:ptr+CHUNK_SIZE])
ptr += CHUNK_SIZE
fn.close()
fh.close()


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


list from FTP server to a text file

2011-01-06 Thread Ahmed, Shakir
Hi,

I am trying to create a list in a txt file from an ftp server. The
following code is retrieving the list of the files but could not able to
write in a text file. Any help is highly appreciated.

Thanks


 
 
import os
import time
from ftplib import FTP
ftp = FTP(*.org,,)   # connect to host, default port
ftp.login()
ftp.cwd(/pub/remotefolder/)
ftp.retrlines('NLST')
**
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: list from FTP server to a text file

2011-01-06 Thread Ahmed, Shakir


-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Dan M
Sent: Thursday, January 06, 2011 11:06 AM
To: python-list@python.org
Subject: Re: list from FTP server to a text file

On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote:

 Hi,
 
 I am trying to create a list in a txt file from an ftp server. The
 following code is retrieving the list of the files but could not able
to
 write in a text file. Any help is highly appreciated.
 
 Thanks
 
 
 
 
 import os
 import time
 from ftplib import FTP
 ftp = FTP(*.org,,)   # connect to host, default port ftp.login()
 ftp.cwd(/pub/remotefolder/)
 ftp.retrlines('NLST')
 **

WARNING: I am a newbie! Expect more pythonic ways to do this in other 
replies

from ftplib import FTP
ftp = FTP(host, user, pass)
ftp.cwd(/pub/myfolder)
files = ftp.nlst(.)
f = open('files.txt', 'w')
for file in files:
f.write('%s\n' % (file,))
f.close()

-- 

It worked 
Thanks, 
shk
-- 
http://mail.python.org/mailman/listinfo/python-list


Data source path of a lyer file

2010-10-07 Thread Ahmed, Shakir
Hi,

Is there any way that I can read the data source path of a .lyr file
using Arc Object gp processor.

 

Thanks

sa

 

 

 

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


error on exe file

2010-06-16 Thread Ahmed, Shakir
HI,

 

I created a script to do some GIS process ( basic GIS operation exam:
create shape file, project and copy)  and exporting one of the output to
dbf too. The Script is running without any problem where ArcGIS and
python are installed. I need to runt this application where both of the
application is not installed. I created an exe file from the py file,
the file is running perfectly alright in those machines where Arc GIS is
installed locally but the exe file is giving memory error on those
machines where Arc GIS is not installed. 

 

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


RE: Reading data from a Microsoft Access 2003 database

2010-05-19 Thread Ahmed, Shakir

-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Simon Brunning
Sent: Wednesday, May 19, 2010 6:13 AM
To: python-list
Subject: Re: Reading data from a Microsoft Access 2003 database

On 19 May 2010 10:28:15 UTC+1, Jimoid jimmy.cul...@gmail.com wrote:
 I use Ubuntu 64 bit and need to develop a programme (ideally in
 Python) to work on data that is contained in a Microsoft Access 2003
 database. I do not need to modify the database, simply read a few
 columns of data from some tables.

mxODBC might well be what you are looking for,

-- 
Cheers,
Simon B.
-- 

Or you can use pyodbc
DBfile = '/path/*.mdb
conn = pyodbc.connect('DRIVER={Microsoft Access Driver
(*.mdb)};DBQ='+DBfile, autocommit=True)
cursor = conn.cursor()

Thanks
Shakir

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


RE: Python, CGI and Sqlite3

2010-04-13 Thread Ahmed, Shakir
-Original Message-
From: python-list-bounces+shahmed=sfwmd@python.org
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of
Tim Chase
Sent: Tuesday, April 13, 2010 2:36 PM
To: Majdi Sawalha
Cc: python-list@python.org
Subject: Re: Python, CGI and Sqlite3

On 04/13/2010 12:41 PM, Majdi Sawalha wrote:
 import sqlite3

 statement? and it gives the following error
 ImportError: No module named sqlite3,

 i tried it on python shell and all statements are work well.

A couple possible things are happening but here are a few that 
pop to mind:

1) you're running different versions of python (sqlite was 
bundled beginning in 2.5, IIRC) so when you run from a shell, you 
get python2.5+ but your CGI finds an older version.  Your CGI can 
dump the value of sys.version which you can compare with your 
shell's version

2) the $PYTHONPATH is different between the two.  Check the 
contents of sys.path in both the shell and the CGI program to see 
if they're the same.  You might also dump the results of 
os.environ.get('PYTHONPATH', None)  to see if an environment 
variable specifies the $PYTHONPATH differently

3) while it reads correctly above, it's theoretically possible 
that you have a spelling error like import sqllite3?  I've been 
stung once or twice by this sort of problem so it's not entirely 
impossible :)

-tkc

Tim is right, following import works fine with me.

import sqlite3 






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

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


RE: memory error

2009-12-04 Thread Ahmed, Shakir
 

 

From: python-list-bounces+shahmed=sfwmd@python.org 
[mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of Stephen 
Hansen
Sent: Thursday, December 03, 2009 10:22 PM
To: python-list@python.org
Subject: Re: memory error

 

On Thu, Dec 3, 2009 at 5:51 AM, Ahmed, Shakir shah...@sfwmd.gov wrote:

I am getting a memory error while executing a script. Any idea is highly
appreciated.

Error message:  The instruction at 0x1b009032 referenced memory at
0x0804:, The memory could not be written

This error is appearing and I have to exit from the script.

 

Vastly insufficient information; that basically is like saying, Something 
broke. People can't really help you with that. You sorta need to show some 
code and/or at least describe what's going on at the time.

 

But-- the image does say Pythonwin... are you running this from the Pythonwin 
editor/IDE? Does this script crash out if you run it through the normal 
'python'(or pythonw) commands? If not, are you attempting to do any sort of GUI 
work in this script? That rarely works within Pythonwin directly.

 




--S

 

I am using python to do some gp ( geo processing ) for accuracy analysis. This 
analysis is based on application numbers. The script is going through each 
application number to process the data and looping through. The error appears 
after running few loops ( mean it process few applications). There is no 
certainty of how many loops it is going through but stopped with the error 
message and.

 

The code is attached herewith so I  hope it would make more clear to you. Any 
help is highly appreciated.

 

--sk 

 



ReverseBufferOverLay.py
Description: ReverseBufferOverLay.py
-- 
http://mail.python.org/mailman/listinfo/python-list


Data uploading to a ftp server

2009-04-16 Thread Ahmed, Shakir

I am getting following error while uploading data to a ftp server. Any
help is highly appreciated.


ftp.storbinary(stor erp.shp, ffile2,8192)
  File C:\Python24\lib\ftplib.py, line 419, in storbinary
conn.sendall(buf)
  File string, line 1, in sendall
error: (10054, 'Connection reset by peer')

Thanks 
sk

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


date format

2009-01-21 Thread Ahmed, Shakir
I am grabbing few fields from a table and one of the columns is in date
format. The output which I am getting is Wed Feb 09 00:00:00 2005 but
the data in that column is 02/09/2005 and I need the same format
output to insert those recodes into another table.

print my_service_DATE
Wed Feb 09 00:00:00 2005

Any help is highly appreciated.

sk

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


RE: removing text string

2008-09-11 Thread Ahmed, Shakir
Thanks

Actually the number I am getting it is from slicing from a long text
line. I need to slice 10 characters from that line but no string only
numeric numbers. When I am slicing 10 characters those A, c, O is coming
at the end. 

Thanks


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Dennis Lee Bieber
Sent: Wednesday, September 10, 2008 3:45 PM
To: python-list@python.org
Subject: Re: removing text string

On Wed, 10 Sep 2008 11:22:16 -0400, Ahmed, Shakir [EMAIL PROTECTED]
declaimed the following in comp.lang.python:

 I need to remove text string from the list of the numbers mentioned
 below:
 
 080829-7_A
 070529-5_c
 080824-7_O
 070405_6_p
 
?   Is that last one an error that is supposed to be
...5-6_, not
...5_6_ ?

1)  If the required data is fixed width, just slice it

out = inp[:8]

2)  If the data is variable width but has a fixed delimiter,
find
the delimiter position and then slice (this is the reason for my
question above -- this method) OR just split on the delimiter and take
the part you need.

out = inp.split(_)[0]

3)  If the data is more complex (again if that last line
with two _
is supposed to be trimmed after the second, and the first turned into a
-) you will need to fully define the parsing rules of the data.
-- 
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

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


RE: removing text string

2008-09-11 Thread Ahmed, Shakir


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, September 11, 2008 8:54 AM
To: python-list@python.org
Subject: Re: removing text string

Ahmed, Shakir:
 Actually the number I am getting it is from slicing from a long text
 line. I need to slice 10 characters from that line but no string only
 numeric numbers. When I am slicing 10 characters those A, c, O is
coming
 at the end.

It's better to avoid Regular expressions when they aren't necessary,
but once in a while they are the simpler way to solve a problem, you
may create one like this (mostly untested):

\d+?-\d+

Using it like:

 import re
 patt = re.compile(r\d+?-\d+)
 patt.search(xx080829-7_A ).group()
'080829-7'
 re.search(r\d+?-\d+, xx080829-7_A ).group()
'080829-7'

Learning Regexps can be useful.

Bye,
Bearophile


Thanks, I got the clue.

Very much appreciated.


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

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


removing text string

2008-09-10 Thread Ahmed, Shakir
I need to remove text string from the list of the numbers mentioned
below:

080829-7_A
070529-5_c
080824-7_O
070405_6_p

The output will be : 080829-7
 070529-5
 080824-7
 070405-6  

Any idea is highly appreciated.



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


RE: Using strftime

2008-09-03 Thread Ahmed, Shakir

You can try

Import time
mytimeymd = time.strftime('%y%m%d')

print mytimeymd


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
frankrentef
Sent: Wednesday, September 03, 2008 1:21 PM
To: python-list@python.org
Subject: Using strftime

I have one line of code that put's an old date in my code.


ie.textBoxSet('_ct10_PlaceHolder_txtEnd', '8/15/2008')



What I wish to do in another similiar line is have the field populated
with the current system date?  How best to do this?  I've read some of
the strftime documentation but as of yet I'm unable to get it to work
correctly.


Help is appreciated.

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

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


RE: help with parsing email

2008-08-18 Thread Ahmed, Shakir
Thanks everyone who tried to help me to parse incoming email from an exchange 
server:

Now, I am getting following error; I am not sure where I am doing wrong. I 
appreciate any help how to resolve this error and extract emails from an 
exchange server. 


First I tried:
 mailserver = 'EXCHVS01.my.org'
 mailuser = 'myname'
 mailpasswd = 'mypass'
 mailserver = poplib.POP3(mailserver)
Traceback (most recent call last):
  File interactive input, line 1, in ?
  File C:\Python24\lib\poplib.py, line 96, in __init__
raise socket.error, msg
error: (10061, 'Connection refused')



The other way:

 mailserver = 'pop.EXCHVS01.ad.my.org'
 mailuser = '[EMAIL PROTECTED]'
 mailpasswd = 'mypass'
 mailserver = poplib.POP3(mailserver)
Traceback (most recent call last):
  File interactive input, line 1, in ?
  File C:\Python24\lib\poplib.py, line 84, in __init__
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
gaierror: (11001, 'getaddrinfo failed')


I tried above ways but getting error

Thanks
sk

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabriel Genellina
Sent: Monday, August 18, 2008 6:43 AM
To: python-list@python.org
Cc: [EMAIL PROTECTED]
Subject: Re: help with parsing email

En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir [EMAIL PROTECTED] escribió:

 I need to grab/parse numeric numbers such as app number from incoming
 emails stored in Microsoft Outlook (Microsoft Exchange server) with
 specified subject line.

 The email body is like this

 myregion ; tst ; 11-Aug-2008

 http://my.xyz.com//content/ifs/apps/myDocFolder/NoticeOfapplication/080612-21_test_337683.pdf

 I need to extract 080612-21_ number from above line from incoming
 emails.

Help from Maric Michaud [EMAIL PROTECTED]

Three options here :

- dealing directly with outlook mailboxes files, I used some open source code 
to parse .pst files in past, but you'll need some googling to match your 
requirements. Doesn't help if there is an instance of outlook running on the 
box.

- use the outlook COM or even some windows MAPI interface via WIN32 API 
(pywin32), can't help with this one.

- access emails directly on the Exchange server via standard python modules 
poplib or imaplib, my preferred choice if one of these protocols are 
supported by your environment. You won't need no extensions, just a standard 
python installation, and your code will work with most mail delivery agent 
and will run on all python supported platform.


==
Help from Gabriel Genellina

I can't help with the part dealing with Outlook - but once you retrieved the 
email body, it's easy:

import re
re_number = re.compile(rNoticeOfapplication/([0-9-_]+))
match = re_number.search(body)
if match:
  print match.group(1)

(this matches any numbers plus - and _ after the words NoticeOfapplication 
written exactly that way)

-- 
Gabriel Genellina

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

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


RE: help with parsing email

2008-08-18 Thread Ahmed, Shakir


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Werner F. Bruhin
Sent: Monday, August 18, 2008 1:04 PM
To: python-list@python.org
Cc: [EMAIL PROTECTED]
Subject: Re: help with parsing email

Ahmed, Shakir wrote:
 Thanks everyone who tried to help me to parse incoming email from an
exchange server:
 
 Now, I am getting following error; I am not sure where I am doing
wrong. I appreciate any help how to resolve this error and extract
emails from an exchange server. 
 
 
 First I tried:
 mailserver = 'EXCHVS01.my.org'
 mailuser = 'myname'
 mailpasswd = 'mypass'
 mailserver = poplib.POP3(mailserver)
 Traceback (most recent call last):
   File interactive input, line 1, in ?
   File C:\Python24\lib\poplib.py, line 96, in __init__
 raise socket.error, msg
 error: (10061, 'Connection refused')
 
 
 
 The other way:
 
 mailserver = 'pop.EXCHVS01.ad.my.org'
 mailuser = '[EMAIL PROTECTED]'
 mailpasswd = 'mypass'
 mailserver = poplib.POP3(mailserver)
 Traceback (most recent call last):
   File interactive input, line 1, in ?
   File C:\Python24\lib\poplib.py, line 84, in __init__
 for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
 gaierror: (11001, 'getaddrinfo failed')
Haven't used poplib myself, but was intrigued.

Did you see this:
http://www.python.org/doc/lib/pop3-example.html

To me it looks like you are not setting the user/password.

So, maybe something like:

M = poplib.POP3(mailserver)
M.user(mailuser)
M.pass_(mailpasswd)


Werner

--

but I am getting error before that point and could not go to the user
account or pass.

M = poplib.POP3(mailserver)
Traceback (most recent call last):
  File interactive input, line 1, in ?
  File C:\Python24\lib\poplib.py, line 96, in __init__
raise socket.error, msg
error: (10061, 'Connection refused')


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


help with parsing email

2008-08-14 Thread Ahmed, Shakir
Hi all,

 

I do appreciate if any one can help me for my following problem:

 

I need to grab/parse numeric numbers such as app number from incoming
emails stored in Microsoft Outlook (Microsoft Exchange server) with
specified subject line. 

 

Any help with the python script is highly appreciated.

 

The email body is like this

 

myregion ; tst ; 11-Aug-2008

http://my.xyz.com//content/ifs/apps/myDocFolder/NoticeOfapplication/
080612-21_test_337683.pdf

 

 

I need to extract 080612-21_ number from above line from incoming
emails.

 

 

Thanks

sk

 

 

 

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

parsing incoming emails

2008-07-10 Thread Ahmed, Shakir
HI,

 

I am working on a project where I need to parse incoming emails
(Microsoft outlook)  with a specific subject into an excel file or a
Microsoft access table. 

 

I am using python for my GIS works but not sure how I can use python
script here to work with Microsoft outlook email. 

 

Any help or idea is highly appreciated.

 

Thanks

SA

 

 

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

need to parse html to microsoft access table

2008-06-20 Thread Ahmed, Shakir
I need help to parse html file into Microsoft Access database table.
Right now I could parse it in a csv file but the way it is parsing is
not that I want and I could not import the list into access table as the
information is parsing one after another and it is not a row column
format. 

 

 

Any help is highly appreciated.

 

Thanks in advance

sk

 

 

 

 

 

Name:



 

Registered Office Address:

Xx 

 

 

 

 

 

 

Xxxx

 

 

Telephone:

(xx

 

 

Fax:

(xxx) xxx 

 

 

E-Mail:

[EMAIL PROTECTED] 

 

Website:

 

 

 

 

Status:

X

 

 

County(ies):

x 

 

 

Local Governing Authority:

Xxx 

 

 

Function(s):

X

X

Date Established:

6/15/1953

 

 

 

Creation Documents:

Xxxx

 

Statutory Authority:

 

 

Board Selection:

x

 

 

 

Authority to Issue Bonds:

x

 

 

 

Revenue Source:

 x

 

 

Most Recent Update:



 

 

 

Creation Method:

xxx 

 

 

 

 

 

 

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

Removing Space and - from a string

2008-05-20 Thread Ahmed, Shakir
I have thousands of records in MS Access database table, which records I
am fetching using python script. One of the columns having string like 
'8 58-2155-58'

Desired output: '858215558'

I want to remove any spaces between string and any dashes between
strings. I could do it in access manually but want to do from python
script 

Any help is highly appreciated.

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


RE: Removing Space and - from a string

2008-05-20 Thread Ahmed, Shakir
Thanks, works exactly what I needed.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, May 20, 2008 12:22 PM
To: python-list@python.org
Subject: Re: Removing Space and - from a string

On May 20, 11:02 am, Ahmed, Shakir [EMAIL PROTECTED] wrote:
 I have thousands of records in MS Access database table, which records
I
 am fetching using python script. One of the columns having string like
 '8 58-2155-58'

 Desired output: '858215558'

 I want to remove any spaces between string and any dashes between
 strings. I could do it in access manually but want to do from python
 script

 Any help is highly appreciated.

string.replace('-', '').replace(' ', '')
--
http://mail.python.org/mailman/listinfo/python-list

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


RE: Pythonwin

2008-05-09 Thread Ahmed, Shakir
You need to install the same version on your pc, if you have 2.5 already 
installed you need to download 2.5 pythonwin from http://sourceforge.net

Hope it will work for you.
Thanks
sk


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Clive_S
Sent: Friday, May 09, 2008 9:41 AM
To: python-list@python.org
Subject: Re: Pythonwin

Hi all

I downloaded (from Python) and installed python-2.4.4.msi

I have python and pythonw.exe in the Python 24 folder (but not in my
start menu).
When I click on the pythonw.exe it is not launched??

Thanks

Clive


On 9 May, 14:09, Mike Driscoll [EMAIL PROTECTED] wrote:
 On May 9, 5:30 am, Clive_S [EMAIL PROTECTED] wrote:

  Hi
  I am trying to use Python with ArcGIS.
  I have installed Python 2.4. I have an icon for IDLE and command line.
  I do not see Python PythonWin.
  How do you install or launch pythonwin??
  Thanks
  Clive

 I have PythonWin installed in my Start Menu -- Programs -- Python
 2.5. I may have installed the ActiveState version though. Just check
 if it's there on your system and if not, you can follow Niklas's
 advice.

 Mike

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

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


Error Message

2008-04-23 Thread Ahmed, Shakir
I am getting application error message  The instruction at 0x7c910f29
referenced memory at 0x. The memory could not be read. I am
running one python script and it is running good without any exception
or error message but getting this message when I am closing python 2.4.1
application. 

 

Any idea or help is highly appreciated.

 

Thanks

sk

 

 

 

 

 

 

 

 

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

Deleting Microsoft access database

2008-03-20 Thread Ahmed, Shakir
I have a Microsoft Access database that I want to delete whether anyone
is using that file. 

The database is already read only mode residing in a server, users are
opening in read only mode. I want to delete that file, I remove read
only check but could not delete that file. 

Getting error message: 
Cannot delete xxx : It is being used by another person or program. 

Any help is highly appreciated.

Thanks
sa


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


Accessing Oracle/Access database py2.4

2008-02-15 Thread Ahmed, Shakir
I was used import odbc  to connect oracle or access table before, now I
switched to python 2.4 and is giving me error message. I appreciate any
help on that. 

 

Thanks

sh

 

 

 

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

Table update

2007-08-28 Thread Ahmed, Shakir

I am trying to use python script to update a table by incremental value
based on struc_No but having problem to get right result on the value
field for the 3rd and 4th same number of struc_no. 

I need to update the Value field only with the incremental value of 15
or so

Any help is highly appreciated.

Thanks
Shak



Input table or source table

ID  struc_idStruc_NoValue   
1   ABC 100110  
2   EFJ 100515  
3   HIK 100310  
4   ILK 100510  
5   PIO 10018   
6   TIN 100112  
7   MNO 100111  
8   POW 100318  


Output Table

ID  struc_idStruc_NoValue   Added value
1   ABC 100125  15
2   EFJ 100530  15
3   HIK 100325  15
4   ILK 100540  30
5   PIO 100138  30
6   TIN 100157  45
7   MNO 100171  60
8   POW 100348  30


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


shutil.copyfile problem for GIS data

2007-07-16 Thread Ahmed, Shakir

Need help to copy a personal geodatabase from one location to another:


Trying to copy a personal geodatabase from one location to another
location where all the users are retrieving data from the second
location:

1.  I can copy over the updated personal geodatabase to the working
location and overwrite it, though the file is opened by ArcGIS  users
(Local Installation of Arc GIS  on the users computers).


2.  But problem is that  I can't copy over if the same updated
personal geodatabase to the working location,  if users uses that same
geodatabase through CITRIX - ArcGIS ( user does not have  permission to
edit the data)

3.  the python script which I am using as follows:

import shutil
import os

src = c:\mydata\test\mygeo.mdb
dst = v:\updated\data\mygeo.mdb

shutil.copyfile(src,dst)

I highly appreciate if any one of you can help me and give me a
direction that I can solve this problem.

Thanks in advance.

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


permission denied in shutil.copyfile

2007-07-13 Thread Ahmed, Shakir
Is there any way to copy a file from src to dst if the dst is
exclusively open by other users.

I am using 

src  = 'c:\mydata\data\*.mdb'
dst = 'v:\data\all\*.mdb'

shutil.copyfile(src,dst)

but getting error message permission denied.

Any help is highly appreciated.

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


RE: Who uses Python?

2007-06-04 Thread Ahmed, Shakir



I mean other than sysadmins, programmers, and web-site developers?

I have heard of some DBAs who use a lot of python.

I suppose some scientists. I think python is used in bioinformatics. I
think some math and physics people use python.

I suppose some people use python to learn programming in general.
Python would do well as a teaching language.

I would think that python would be a good language for data analysis.

Anything else? Finance? Web-analytics? SEO? Digital art?

 I use for GIS Data automation in the backend and gradually replacing
all old VBA application with the Python scripts.

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


Copy geodatabase(mdb) if it is locked

2007-03-08 Thread Ahmed, Shakir
I am trying to copy a geodatabase (.mdb) file from source to destination
using

shutil.copyfile(src, dest)

 

It is working fine but the main problem when the destination (.mdb) file
is locked by other users then it's bumped out and not copied over.

 

Is there any way to copy the locked .mdb file and overwrite it.

 

Any help is highly appreciated.

 

shakir

 

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

GIS Shape file upload FTP server

2007-03-01 Thread Ahmed, Shakir
HI Group,

 

As I am very new in python field so this question might be very silly
but If I get any help that is highly appreciated.

 

Problem: 

 

I have a python script which is working fine to upload files to the ftp
server but the problem is it is reducing the actual size after
transferring. I need to upload a GIS Shape file to the ftp server but
want to keep the same size and format. Any idea or help is highly
appreciated.

 

Thanks

Shakir

Staff Geographer

Sfwmd.gov

 

The code is as follows: 

 

 

# Import system modules

 

import os

import sys 

import win32com.client

import zipfile

import os.path

import ftplib

from ftplib import FTP

 

 

ftp=ftplib.FTP(ftp.sfwmd.gov,,)  

ftp.login('sahmed','sa1lf1sh')

#ftp.cwd(/export/pub/sahmed)

 

ffile = open('c:\\test\\wuppnt.shp', 'r')

 

ftp.storbinary(stor wuppnt.shp, ffile)

ffile.close()

 

print OK

ftp.quit()

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

GIS Shape file upload to FTP server

2007-03-01 Thread Ahmed, Shakir
HI Group,

As I am very new in python field so this question might be very silly to
you but if I get any help is highly appreciated.

Problem: 

I wrote a python script which is working fine to upload files to the ftp
server but the problem is it is reducing the actual size after
transferring. I need to upload a GIS Shape file to the ftp server but
want to keep the same size and format. Any idea or help is highly
appreciated.

 
Thanks

Shakir
Staff Geographer
Sfwmd.gov

The code is as follows: 

===
# Import system modules

 

import os
import sys 
import win32com.client
import zipfile
import os.path
import ftplib
from ftplib import FTP


ftp=ftplib.FTP(ftp.sfwmd.gov,,)  
ftp.login('sahmed','sa1lf1sh')
#ftp.cwd(/export/pub/sahmed)
ffile = open('c:/test/wuppnt.shp', 'r')

ftp.storbinary(STOR wuppnt.shp, ffile)
ffile.close()

print OK
ftp.quit()
-- 
http://mail.python.org/mailman/listinfo/python-list