Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Rename of .mdb file -- lock
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
noydb  
View profile  
 More options Dec 11 2008, 9:15 pm
Newsgroups: comp.lang.python
From: noydb <jenn.du...@gmail.com>
Date: Thu, 11 Dec 2008 18:15:59 -0800 (PST)
Local: Thurs, Dec 11 2008 9:15 pm
Subject: Rename of .mdb file -- lock
All,

I have the code below, which unzips a zipfile containing only one
file.  Once it is unzipped, I want to rename the file based on a user
provided name.  But I get this (WindowsError: [Error 32] The process
cannot access the file because it is being used by another process)
error, which does not make sense to me as no other apps are open.

Any suggestions?

Thanks!

****CODE****
# Declare the zip file directory and name (shouldn't change, in a
permanent location)
mdb_zip = ("C:\\ProjWork\\mdb_geoDB_91.zip")

output_dir = ("C:\\Temp")

# ZipFile for read
z = zipfile.ZipFile(mdb_zip, 'r')
zFile = z.namelist()

# Put contents of zipfile into a list
zList = z.namelist()

# Loop thru list, write zipfile contents to new directory
for zItem in zList:
    print "Unpacking",zItem
    zRead = z.read(zItem)
    z1File = open(os.path.join(output_dir, zItem),'wb')
    z1File.write(zRead)
    z1File.close
print "Finished extracting zip file"

uChoice = "test44.mdb" ## to be user chosen someday
new91mdb = os.path.join(output_dir, zItem) # C:\TEMP\GDB_9_1.mdb

##os.rename(new91mdb, (os.path.join(output_dir, uChoice)))
os.rename(new91mdb, (os.path.join(output_dir, "C:\TEMP\test1.mdb")))

del new91mdb


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gudonghua+python@gmail.co m  
View profile  
 More options Dec 11 2008, 9:38 pm
Newsgroups: comp.lang.python
From: "gudonghua+pyt...@gmail.com" <gudong...@gmail.com>
Date: Thu, 11 Dec 2008 18:38:03 -0800 (PST)
Local: Thurs, Dec 11 2008 9:38 pm
Subject: Re: Rename of .mdb file -- lock
On Dec 12, 10:15 am, noydb <jenn.du...@gmail.com> wrote:

     z1File.close()


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
noydb  
View profile  
 More options Dec 11 2008, 9:43 pm
Newsgroups: comp.lang.python
From: noydb <jenn.du...@gmail.com>
Date: Thu, 11 Dec 2008 18:43:00 -0800 (PST)
Subject: Re: Rename of .mdb file -- lock
On Dec 11, 9:38 pm, "gudonghua+pyt...@gmail.com" <gudong...@gmail.com>
wrote:

Thanks!  That was simple enough.

And...
##os.rename(new91mdb, (os.path.join(output_dir, uChoice)))
os.rename(new91mdb, (os.path.join(output_dir, "C:\TEMP\test1.mdb")))

... of those two lines, the top one worked.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Holden  
View profile  
 More options Dec 11 2008, 10:42 pm
Newsgroups: comp.lang.python
From: Steve Holden <st...@holdenweb.com>
Date: Thu, 11 Dec 2008 22:42:24 -0500
Local: Thurs, Dec 11 2008 10:42 pm
Subject: Re: Rename of .mdb file -- lock

noydb wrote:
> On Dec 11, 9:38 pm, "gudonghua+pyt...@gmail.com" <gudong...@gmail.com>
> wrote:
[...]

> Thanks!  That was simple enough.

> And...
> ##os.rename(new91mdb, (os.path.join(output_dir, uChoice)))
> os.rename(new91mdb, (os.path.join(output_dir, "C:\TEMP\test1.mdb")))

> ... of those two lines, the top one worked.

The reason the second one didn't work is because "\t" is the tab
character. Look for "raw strings" in the documentation.

r"C:\TEMP\test1.mdb" should work.

regards
 Steve
--
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott David Daniels  
View profile  
 More options Dec 15 2008, 2:01 pm
Newsgroups: comp.lang.python
From: Scott David Daniels <Scott.Dani...@Acm.Org>
Date: Mon, 15 Dec 2008 11:01:02 -0800
Local: Mon, Dec 15 2008 2:01 pm
Subject: Re: Rename of .mdb file -- lock

noydb wrote:
> I have the code below, which unzips a zipfile containing only one
> file.  Once it is unzipped, I want to rename the file based on a user
> provided name.  But I get this (WindowsError: [Error 32] The process
> cannot access the file because it is being used by another process)
> error, which does not make sense to me as no other apps are open.
> Any suggestions?

Others have told you the reason you are currently having problems.
You should also be aware that Windows can at "random" times be opening
the new file in order to either index it or virus scan it, and it may
fail to rename during that period.  So, a failure should retry in a
second a couple of times before giving up.  This is my understanding,
but someone deeply familiar with Windows internals might reveal that
I am operating on older information.

--Scott David Daniels
Scott.Dani...@Acm.Org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MRAB  
View profile  
 More options Dec 15 2008, 2:40 pm
Newsgroups: comp.lang.python
From: MRAB <goo...@mrabarnett.plus.com>
Date: Mon, 15 Dec 2008 19:40:21 +0000
Local: Mon, Dec 15 2008 2:40 pm
Subject: Re: Rename of .mdb file -- lock

It's always a good idea pause and then retry a few times, just in case.
Retrying is also a good idea when deleting a file, although in that case
you might also want to check whether the file is read-only; if it is,
then there's no point in retrying.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »