By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,172 Members | 727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,172 IT Pros & Developers. It's quick & easy.

command line path

P: n/a
I am trying to pass the name of several files to a python script as command
line arguments. When i type in
python ImportFiles_test.py C:\Program Files\National Instruments\LabVIEW
7.1\project\calibration\FREQUENCY_
13.CSV

The following error results:

C:\Program Traceback (most recent call last):
File "C:\Documents and Settings\bm304.BRYANPC\My
Documents\Python\ImportFiles_test.py", line 10, in ?
input = open(file1, 'rb');
IOError: [Errno 2] No such file or directory: 'C:\\Program'

I debugged a little and what is happening is the space in "c:\Program Files"
and "...\National Instruments..\" is being parsed as separate arguments and
i only wish for them to be parsed as one.

How do I get pass a path string containing spaces?

Regards,
Bryan
Sep 5 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
>
I debugged a little and what is happening is the space in "c:\Program Files"
and "...\National Instruments..\" is being parsed as separate arguments and
i only wish for them to be parsed as one.

How do I get pass a path string containing spaces?


Surround it with double quotes. This is no python issue, it's part of
your shell. Under unix (or cygwin) , you could also use '\ ' to escape
the single spaces.

Diez
Sep 5 '05 #2

P: n/a
On 2005-09-05, mclaugb <mc*****@nospam.gmail.com> wrote:
I am trying to pass the name of several files to a python script as command
line arguments. When i type in
python ImportFiles_test.py C:\Program Files\National Instruments\LabVIEW
7.1\project\calibration\FREQUENCY_
13.CSV

The following error results:

C:\Program Traceback (most recent call last):
File "C:\Documents and Settings\bm304.BRYANPC\My
Documents\Python\ImportFiles_test.py", line 10, in ?
input = open(file1, 'rb');
IOError: [Errno 2] No such file or directory: 'C:\\Program'

I debugged a little and what is happening is the space in "c:\Program Files"
and "...\National Instruments..\" is being parsed as separate arguments and
i only wish for them to be parsed as one.

How do I get pass a path string containing spaces?

Try quotes ...

python "ImportFiles_test.py C:\Program Files\National Instruments\LabVIEW 7.1\project\calibration\FREQUENCY_13.CSV"

Sep 5 '05 #3

P: n/a
Lee Harr <le*@example.com> wrote:
On 2005-09-05, mclaugb <mc*****@nospam.gmail.com> wrote:
I am trying to pass the name of several files to a python script as command
line arguments. When i type in

python ImportFiles_test.py C:\Program Files\National Instruments\LabVIEW
7.1\project\calibration\FREQUENCY_13.CSV

The following error results:

C:\Program Traceback (most recent call last):
File "C:\Documents and Settings\bm304.BRYANPC\My
Documents\Python\ImportFiles_test.py", line 10, in ?
input = open(file1, 'rb');
IOError: [Errno 2] No such file or directory: 'C:\\Program'

I debugged a little and what is happening is the space in "c:\Program Files"
and "...\National Instruments..\" is being parsed as separate arguments and
i only wish for them to be parsed as one.

How do I get pass a path string containing spaces?


Try quotes ...

python "ImportFiles_test.py C:\Program Files\National Instruments\LabVIEW 7.1\project\calibration\FREQUENCY_13.CSV"


Right idea, but wrong implementation. What that does is pass one very long
file name as the script file, with no parameters.

This is right, modulo the line splitting:

python ImportFiles_test.py "C:\Program Files\National Instruments\LabVIEW
7.1\project\calibration\FREQUENCY_13.CSV"
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Sep 6 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.