Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'paths': 0.07; 'specifying': 0.07; 'python': 0.08; 'appreciated,': 0.09; 'desktop.': 0.09; 'folder,': 0.09; 'subject:files': 0.09; 'library': 0.13; 'thanks!': 0.14; 'converting': 0.15; 'filenames': 0.16; 'output?': 0.16; 'paths.': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'purposes.': 0.18; 'cc:no real name:2**0': 0.21; 'trying': 0.21; 'file,': 0.21; 'header:In-Reply-To:1': 0.22; 'earlier': 0.23; 'runs': 0.23; 'correct,': 0.23; 'convert': 0.25; 'cc:2**0': 0.26; 'code': 0.26; 'work.': 0.27; 'function': 0.27; 'worked': 0.29; 'cc:addr:python.org': 0.29; 'correct': 0.29; 'pm,': 0.29; 'confident': 0.30; 'ran': 0.30; 'changes': 0.30; 'url:library': 0.31; 'certainly': 0.32; 'does': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'file': 0.34; 'rule': 0.34; 'running': 0.34; 'directory.': 0.34; 'smart': 0.34; 'however,': 0.35; 'trouble': 0.35; 'something': 0.35; 'folder': 0.35; 'url:python': 0.35; 'pull': 0.37; 'but': 0.37; 'using': 0.37; 'enough': 0.38; 'received:192': 0.38; 'could': 0.38; 'some': 0.38; 'doing': 0.38; 'should': 0.38; 'open': 0.38; 'files': 0.39; 'url:org': 0.39; 'subject:from': 0.39; 'absolute': 0.39; 'put': 0.40; 'change': 0.40; 'might': 0.40; 'more': 0.61; 'your': 0.61; 'making': 0.64; 'piece': 0.66; 'to:addr:comcast.net': 0.67; 'exact': 0.68; 'header:Reply-To:1': 0.70; 'reply-to:no real name:2**0': 0.72; 'online,': 0.88; 'from.': 0.93 Date: Tue, 07 Feb 2012 13:40:10 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16 MIME-Version: 1.0 To: SMac2347@comcast.net Subject: Re: Reading files in from the proper directory References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:py6KkFVLd3ftvmxUX2KwmGydWGk1xcKBbrOiimoql7Z iTGvyNGmnoAA4CbtsIFkz7nVee6WQHgbFJXTN2pyc5I+gWApg9 /ny+EgJ6my0UidgYpp0hefV+wtAu46KPZyzML8S2hO2mz+mhy2 UgQI49c1LgXDMJIDB9LVEQ5SK9pteG63MozNXUsb9WK4ggfVtx jfgnFcdhTgd0nwtlCCva6I2jcu6hQbxBQTod2REfKQ5KOZmoHG Kx6L5GIoUTP3l54ETjnhkSZztYq1YvyeDyn7btExUbpRjpOMDq /qs66kNi2GSoOlQEU/wjpST2l522lZquzY5sW0A7eu3ko5HmOc SCyuoSPuZDgzhjMZ0nJE= Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328640027 news.xs4all.nl 6849 [2001:888:2000:d::a6]:45858 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19972 On 02/07/2012 01:14 PM, SMac2347@comcast.net wrote: > Hello. I am admittedly a Python novice, and ran into some trouble > trying to write a program that will pull multiple excel files all into > one file, with each file on a different sheet. > > I am confident most of the code is correct, as the program runs > without any errors and I found the base of it online, making changes > as necessary for my own purposes. However, I am having trouble > specifying the exact directory where my code should be pulling the > files from. All the files are in the same folder, and I have put the > folder on my desktop. Am I correct in thinking that I need to change > the current working directory to this folder in order for Python to > read in these files, No, Python certainly does not constrain you to working with files only in the current working directory. My rule of thumb is never to change the cwd in a Python program. You can use relative paths to open files, or you can use absolute paths. There is even a library function os.path.abspath() for converting a relative path to an absolute one. If you do change cwd during the running of a program, then relative filenames that worked earlier might no longer work. You could convert them all to absolute paths, but that's more work. You can piece together path strings using os.path.join(). It's smart enough to know the path separator for your particular platform. Check out this page: http://docs.python.org/library/os.path.html > then generate my output? Or should I be doing > something else? > > Any and all help is appreciated, thanks! > -- DaveA