Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19972

Re: Reading files in from the proper directory

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 <d@davea.name>
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 <d@davea.name>
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 <f3f576e8-e608-4348-b6ee-fe775d9d1021@x19g2000yqh.googlegroups.com>
In-Reply-To <f3f576e8-e608-4348-b6ee-fe775d9d1021@x19g2000yqh.googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5508.1328640027.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Reading files in from the proper directory SMac2347@comcast.net - 2012-02-07 10:14 -0800
  Re: Reading files in from the proper directory Dave Angel <d@davea.name> - 2012-02-07 13:40 -0500
    Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-07 11:03 -0800
  Re: Reading files in from the proper directory Peter Otten <__peter__@web.de> - 2012-02-07 19:59 +0100
    Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-07 11:13 -0800
      Re: Reading files in from the proper directory John Gordon <gordon@panix.com> - 2012-02-07 20:00 +0000
      Re: Reading files in from the proper directory Peter Otten <__peter__@web.de> - 2012-02-07 21:16 +0100
        Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-09 12:32 -0800
          Re: Reading files in from the proper directory Peter Otten <__peter__@web.de> - 2012-02-09 22:07 +0100
          Re: Reading files in from the proper directory Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-02-09 23:05 -0500
        Re: Reading files in from the proper directory SMac2347@comcast.net - 2012-02-09 12:36 -0800
  Re: Reading files in from the proper directory John Gordon <gordon@panix.com> - 2012-02-07 19:46 +0000

csiph-web