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


Groups > comp.lang.python > #19981

Re: Reading files in from the proper directory

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'escape': 0.04; 'interpreter': 0.05; 'inserts': 0.07; 'python': 0.08; 'backslash': 0.09; 'filename': 0.09; 'interpreting': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'slashes': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'from:addr:web.de': 0.23; 'literal': 0.23; 'skip:m 30': 0.24; 'string': 0.24; 'aggregate': 0.29; "skip:' 10": 0.29; 'pattern': 0.30; 'changing': 0.32; 'header:X-Complaints-To:1': 0.34; 'to:addr:python-list': 0.35; 'received:org': 0.36; 'sequence': 0.37; 'skip:" 10': 0.37; 'necessary.': 0.38; 'skip:o 20': 0.38; 'subject:from': 0.39; 'raw': 0.40; 'to:addr:python.org': 0.40; "you'll": 0.61; 'forward': 0.63
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Reading files in from the proper directory
Date Tue, 07 Feb 2012 21:16:57 +0100
Organization None
References <f3f576e8-e608-4348-b6ee-fe775d9d1021@x19g2000yqh.googlegroups.com> <mailman.5510.1328641121.27778.python-list@python.org> <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084b62d.dip.t-dialin.net
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
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.5511.1328645799.27778.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328645799 news.xs4all.nl 6961 [2001:888:2000:d::a6]:37760
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19981

Show key headers only | View raw


SMac2347@comcast.net wrote:

> xls_files   = glob.glob(in_dir + "*.xls")

Try changing that to

pattern = os.path.join(in_dir, "*.xls")
xls_files = glob.glob(pattern) 

os.path.join() inserts a (back)slash between directory and filename if 
necessary.

> merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS")

If you paste the directory name literal into the interactive interpreter 
you'll be surprised:

>>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS"
'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS'

"\09" is intrpreted as chr(9). Use a raw string to prevent Python from 
interpreting a backslash as the start of an escape sequence

>>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS"
'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS'

or use forward slashes as directory separators.

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