Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 4th, 2004, 02:27 PM
sam_kh918's Avatar
sam_kh918 sam_kh918 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 323 sam_kh918 User rank is Corporal (100 - 500 Reputation Level)sam_kh918 User rank is Corporal (100 - 500 Reputation Level)sam_kh918 User rank is Corporal (100 - 500 Reputation Level)sam_kh918 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 11 h 53 m 49 sec
Reputation Power: 9
Writing output to Excel sheet

Hello,

I'm able to use a python script to write an output to an MS Excel sheet. But the second time I run the same script, it gives me permission error:

Code:
    output= open("C:\Documents and Settings\Sam\Desktop\L24.xls","w")
IOError: [Errno 13] Permission denied: 'C:\\Documents and Settings\\Sam\\Desktop\\L24.xls'


PS. Here I have used the # buttons as was mentioned in one of the "How to post messages" threads, but still when I use preview, the indentation is not conserved.

Last edited by netytan : October 4th, 2004 at 03:01 PM.

Reply With Quote
  #2  
Old October 4th, 2004, 03:07 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,676 Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 21 m 12 sec
Reputation Power: 1083
This error indicates that something else already has the file open. I'm guessing that you have the spreadsheet already open in Excel or something, or perhaps it is a previous running instance of the program which hasn't been killed off yet. Check your Task Manager to be certain.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month

Reply With Quote
  #3  
Old October 4th, 2004, 03:31 PM
sam_kh918's Avatar
sam_kh918 sam_kh918 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 323 sam_kh918 User rank is Corporal (100 - 500 Reputation Level)sam_kh918 User rank is Corporal (100 - 500 Reputation Level)sam_kh918 User rank is Corporal (100 - 500 Reputation Level)sam_kh918 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 11 h 53 m 49 sec
Reputation Power: 9
Thanks alot, yes the page was open and I was trying to write to it!

Reply With Quote
  #4  
Old October 4th, 2004, 03:34 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 10 m 32 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Hey Sam,

Check out your post by clicking on the Edit button; you should be able to see what's changed, and what you need to do to preserve your indentation in future .

Anyway, to explain your error. Usually if the file is in use by another program [locked], or you don't have write permission on the file, then Python shouldn't be able to write to the file. For example...

Quote:
Mark-Smiths-Computer:~ Mark$ cd desktop
Mark-Smiths-Computer:~/desktop Mark$ ls -al
total 32
drwxrwxrw- 6 Mark Mark 204 4 Oct 20:07 .
drwxr-xr-x 17 Mark Mark 578 3 Oct 21:52 ..
-rw------- 1 Mark Mark 6148 3 Oct 21:52 .DS_Store
-rw-r--r-- 1 Mark Mark 0 4 Sep 08:01 .localized
-rw-rw-rw- 1 Mark Mark 6 4 Oct 20:06 SomeFile.txt
Mark-Smiths-Computer:~/desktop Mark$ chmod 111
Mark-Smiths-Computer:~/desktop Mark$ ls -al SomeFile.txt
---x--x--x 1 Mark Mark 6 4 Oct 20:06 SomeFile.txt

Mark-Smiths-Computer:~/desktop Mark$ python
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> fileObject = file('SomeFile.txt', 'w')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 13] Permission denied: 'SomeFile.txt'
>>>


Maybe if you attach the script we could spot the problem. For more info on IOError's you can check out:

http://docs.python.org/lib/module-exceptions.html

Mark.
__________________
programming language development: www.netytan.com Hula


Last edited by netytan : October 4th, 2004 at 03:37 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Writing output to Excel sheet


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT